-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.prod
47 lines (34 loc) · 1.11 KB
/
Dockerfile.prod
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
47
# Builder stage for compiling dependencies
FROM python:3.11-alpine3.20 AS builder
# Install geos-dev and alpine-sdk (which contains the compilers needed for building wheels)
RUN apk update && \
apk upgrade && \
apk add geos-dev alpine-sdk
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Create venv
RUN python -m venv /opt/venv
# Make sure to use the venv
ENV PATH="/opt/venv/bin:$PATH"
# Install dependencies to venv
COPY requirements.txt .
RUN pip install -r requirements.txt
# Actual application runtime stage (without build dependencies)
FROM python:3.11-alpine3.20 AS runtime
# Install geos at system level (needed as a sub-dependency of mapbox-vector-tile)
RUN apk update && \
apk upgrade && \
apk add geos
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
# Copy venv with installed dependencies from the builder stage
COPY --from=builder /opt/venv /opt/venv
# Make sure to use the venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy application code
COPY . /app
EXPOSE 5000
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]