-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (33 loc) · 1.15 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
# syntax=docker/dockerfile:1
FROM python:3.12-alpine as python-base
LABEL maintainer="You <[email protected]>"
# Some flags from https://bmaingret.github.io/blog/2021-11-15-Docker-and-Poetry
ENV PYTHONDONTWRITEBYTECODE=1
ENV POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_VERSION=1.8.2 \
POETRY_VIRTUALENVS_OPTIONS_NO_PIP=true \
POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS=true \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
ENV PATH="$VENV_PATH/bin:$PATH"
# Grab security updates
WORKDIR $PYSETUP_PATH
COPY ./scripts/docker-base-alpine.sh docker-base-alpine.sh
RUN ./docker-base-alpine.sh
# Dependency installation
FROM python-base as poetry-base
LABEL maintainer="You <[email protected]>"
WORKDIR $PYSETUP_PATH
# hadolint ignore=DL3018
RUN apk add --no-cache poetry
# Install project dependencies
COPY /poetry.lock /pyproject.toml ./
RUN --mount=type=cache,target=/root/.cache \
poetry install --only main --no-root --no-directory -n
FROM python-base as tns-api
LABEL maintainer="You <[email protected]>"
COPY --from=poetry-base $VENV_PATH $VENV_PATH
WORKDIR /api
COPY ./api .
COPY ./scripts /scripts
ENTRYPOINT ["/scripts/entrypoint.sh"]