forked from Matvey-Doshchechnikov/lab_grader_web
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbackend.Dockerfile
More file actions
37 lines (26 loc) · 871 Bytes
/
backend.Dockerfile
File metadata and controls
37 lines (26 loc) · 871 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
# Build stage
FROM python:3.12-slim AS builder
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Production stage
FROM python:3.12-slim AS final
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
# Copy Python dependencies from builder stage
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy only necessary application files
COPY main.py .
COPY requirements.txt .
COPY courses/ courses/
COPY grading/ grading/
# Change ownership to non-root user
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]