-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.38 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.38 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
51
52
53
# syntax=docker/dockerfile:1.7
# Builder: create Python venv with deps
FROM python:3.11-slim AS builder
ENV VIRTUAL_ENV=/opt/venv \
PIP_NO_CACHE_DIR=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends build-essential curl ca-certificates; \
python -m venv "$VIRTUAL_ENV"; \
. "$VIRTUAL_ENV/bin/activate"; \
pip install --upgrade pip
WORKDIR /tmp/app
COPY requirements.txt ./
RUN . "$VIRTUAL_ENV/bin/activate" && pip install -r requirements.txt
# Runtime: slim image with only the Python proxy server
FROM python:3.11-slim AS runtime
ENV VIRTUAL_ENV=/opt/venv \
PATH="/opt/venv/bin:$PATH" \
BACKEND=python \
FLASK_PORT=23182
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends tini ca-certificates curl; \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
WORKDIR /app
COPY python_app/ ./python_app/
COPY docker/entrypoint.sh /entrypoint.sh
RUN set -eux; \
addgroup --system geneweb && adduser --system --ingroup geneweb geneweb; \
chown -R geneweb:geneweb /app /entrypoint.sh; \
chmod +x /entrypoint.sh
USER geneweb
EXPOSE 23182
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s CMD curl -fsS http://127.0.0.1:${FLASK_PORT}/health || exit 1
ENTRYPOINT ["/usr/bin/tini","--"]
CMD ["/entrypoint.sh"]