-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.prod
More file actions
50 lines (37 loc) · 1.21 KB
/
Dockerfile.prod
File metadata and controls
50 lines (37 loc) · 1.21 KB
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
48
49
50
# Builder stage for compiling dependencies
FROM python:3.12-alpine3.21 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.12-alpine3.21 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 ./webapp /app/webapp
COPY ./migrations /app/migrations
COPY ./data /app/data
COPY ./.flaskenv /app/.flaskenv
EXPOSE 5000
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]