generated from pythoninthegrasses/python_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (39 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
50 lines (39 loc) · 1.28 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
#! can parametrize with build-arg
FROM python:3.11-slim-bullseye
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
# ! missing arg (`-y`), 2 layers, no multi-stage
# install dependencies
RUN apt -qq update && apt -qq install -y curl gcc lsof python3-dev
RUN rm -rf /var/lib/apt/lists/*
# pip env vars
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100
# poetry env vars
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VERSION=1.4.2
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV POETRY_NO_INTERACTION=1
# path
ENV VENV="/opt/venv"
ENV PATH="$POETRY_HOME/bin:$VENV/bin:$PATH"
#! extra layer
# working directory (creates dir if it doesn't exist)
RUN mkdir -p /app
WORKDIR /app
# copy all files from current dir to working dir
COPY . .
#! extra layers
# install poetry and dependencies
RUN python -m venv $VENV && . "${VENV}/bin/activate"
RUN python -m pip install "poetry==${POETRY_VERSION}"
RUN poetry install --no-ansi --no-root --without dev
#! hard-coded port
# listening port (not published)
EXPOSE 3000
#! runs as root
# ENTRYPOINT ["python", "main.py"]
ENTRYPOINT ["/bin/sh", "startup.sh"]
CMD ["5000"] #! hard-coded port
# CMD ["gunicorn", "-c", "gunicorn.conf.py", "main:app"] #! missing poetry call
# CMD ["/bin/bash"]