-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (36 loc) · 1.04 KB
/
Dockerfile
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
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim
ENV FLASK_ENV=production
# Ensure Python output is sent straight to terminal (e.g., for Docker logs)
ENV PYTHONUNBUFFERED=1
ENV PORT=8000
ENV WORKERS=4
RUN adduser python
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install inet utils. Remove once the app is well tested
RUN apt-get update && apt-get install -y \
iputils-ping \
iproute2 \
netcat-traditional \
net-tools \
curl \
dnsutils \
procps \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=python:python requirements.txt /app/
RUN pip install --no-cache-dir --no-compile -r requirements.txt
# App
COPY --chown=python:python app /app/app
# Migrations
COPY --chown=python:python alembic.ini /app/
COPY --chown=python:python migrations /app/migrations
# Precompile Python files
RUN python -m compileall .
COPY entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
USER python
CMD ["/app/entrypoint.sh"]