-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (31 loc) · 1.21 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
# temp stage
FROM python:3.11.4-slim-buster as builder
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y --no-install-recommends gcc
COPY requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
# final stage
FROM python:3.11.4-slim-buster
WORKDIR /app
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN apt-get update && apt-get install -y --no-install-recommends netcat
RUN pip install --no-cache /wheels/*
COPY ./entrypoint.sh .
RUN sed -i 's/\r$//g' ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
COPY . .
RUN addgroup --gid 1001 --system app && \
adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group app
USER app
ENTRYPOINT ["./entrypoint.sh"]
# TODO: Cache Python Packages to the Docker Host
# TODO: only COPY what is needed
# TODO: HEALTHCHECK CMD curl --fail http://localhost:8000 || exit 1
# TODO: add a health check to a Docker Compose file
# TODO: add envars via --mount=type=secret
# TODO: use gunicorn --worker-tmp-dir /dev/shm config.wsgi -b 0.0.0.0:8000
# TODO: update dockerfile.json snippet
# TODO: use docker scan before deployment