-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (28 loc) · 882 Bytes
/
Dockerfile
File metadata and controls
41 lines (28 loc) · 882 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
# ------------------------------
# Builder Stage
# ------------------------------
FROM python:3.10-alpine AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /install
# System deps
RUN apk add --no-cache build-base
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --prefix=/install --no-cache-dir -r requirements.txt
# ------------------------------
# Final Stage
# ------------------------------
FROM python:3.10-alpine
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/install/bin:$PATH"
# Copy installed deps
COPY --from=builder /install /install
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY ./app ./app
USER appuser
EXPOSE 8000
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "app.main:app", "--bind", "0.0.0.0:8000", "--workers", "4"]