-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (42 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
60 lines (42 loc) · 1.48 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
54
55
56
57
58
59
60
# syntax=docker/dockerfile:1
FROM python:3.12-slim-bullseye AS builder
ENV POETRY_VERSION=1.8.3 \
POETRY_NO_INTERACTION=1 \
PIP_NO_CACHE_DIR=on \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml poetry.lock* ./
RUN pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
&& poetry export --only main --without-hashes -f requirements.txt -o requirements.txt
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
RUN pip install --no-cache-dir -r requirements.txt
FROM python:3.12-slim-bullseye AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:${PATH}" \
APP_DIR=/app
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
libpq5 \
postgresql-client \
&& rm -rf /var/lib/apt/lists/* \
&& addgroup --system app && adduser --system --ingroup app --home /app app
COPY --from=builder /opt/venv /opt/venv
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
COPY visitor_system visitor_system
COPY templates templates
COPY grafana grafana
RUN chown -R app:app /app
USER app
EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["gunicorn", "visitor_system.asgi:application", "-k", "uvicorn.workers.UvicornWorker", "-w", "2", "-b", "0.0.0.0:8000"]