Select Git revision
admin-bootstrap.css
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Dockerfile 1.34 KiB
FROM python:3-alpine as base
FROM base as builder
# python
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
# make poetry create the virtual environment in the project's root
# it gets named `.venv`
POETRY_VIRTUALENVS_IN_PROJECT=true \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
\
# paths
# this is where our requirements + virtual environment will live
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
# prepend venv to path
ENV PATH="$VENV_PATH/bin:$PATH"
# install poetry
# hadolint ignore=DL3018
RUN apk add --no-cache poetry build-base python3-dev
# copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY poetry.lock pyproject.toml ./
# install deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry install
# copy the rest of the app
COPY shortlinks shortlinks
COPY Makefile ./
RUN poetry run pyinstaller shortlinks/cli.py --onefile --name shortlinks
FROM base
COPY --from=builder /opt/pysetup/dist/shortlinks /usr/local/bin/shortlinks
CMD ["/usr/local/bin/shortlinks"]