-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (35 loc) · 1.52 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (35 loc) · 1.52 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
# syntax=docker/dockerfile:1.7
FROM python:3.12-slim-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_NO_BUILD_ISOLATION=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /build
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY backend/requirements.txt .
RUN python -m venv /opt/venv \
&& /opt/venv/bin/pip install --upgrade "pip<26" "setuptools<82" "wheel<1" \
&& /opt/venv/bin/pip install --no-cache-dir -r requirements.txt
FROM python:3.12-slim-bookworm AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HOME=/tmp \
PATH="/opt/venv/bin:$PATH" \
FLASK_DEBUG=0
WORKDIR /app
RUN groupadd --system socialfinder \
&& useradd --system --gid socialfinder --home-dir /app --no-create-home socialfinder \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
COPY --chown=socialfinder:socialfinder backend/ /app/
USER socialfinder
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python -c "import os, urllib.request; path=os.getenv('INTERNAL_HEALTH_PATH','/_internal/healthz'); urllib.request.urlopen('http://127.0.0.1:3000' + path, timeout=3).read()"
CMD ["gunicorn", "--bind", "0.0.0.0:3000", "--workers", "2", "--threads", "4", "--timeout", "180", "app:app"]