-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (33 loc) · 971 Bytes
/
Dockerfile
File metadata and controls
46 lines (33 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# syntax=docker/dockerfile:1
# Stage 1: Build dependencies
FROM python:3.13-slim AS builder
# Prevent .pyc files and enable unbuffered stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Stage 2: Final image
FROM python:3.13-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Create non-root user
RUN useradd --create-home appuser
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local /usr/local
ENV PATH=/usr/local/bin:$PATH
# Copy application code
COPY . .
# Set permissions
RUN chown -R appuser:appuser /app
USER appuser
# Expose port and use entrypoint script
EXPOSE 8000
ENTRYPOINT ["/app/docker/entrypoint.sh"]