ARG APP_USER_UID=10001 ARG APP_USER_GID=10001 ARG IMAGE_TAG=development.000000 FROM python:3.10.14-slim-bookworm AS base ARG APP_USER_UID ARG APP_USER_GID ARG IMAGE_TAG ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=off \ PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DEFAULT_TIMEOUT=100 \ PIP_INDEX_URL="https://nexus.bthlabs.pl/repository/pypi/simple/" \ POETRY_VERSION=1.7.1 \ POETRY_HOME="/srv/poetry" \ POETRY_NO_INTERACTION=1 \ VIRTUAL_ENV="/srv/venv" \ KEEP_IT_SECRET_IMAGE_TAG=${IMAGE_TAG} RUN if [ ! $(getent group ${APP_USER_GID}) ];then groupadd -g ${APP_USER_GID} app; fi && \ useradd -m -d /home/app -u ${APP_USER_UID} -g ${APP_USER_GID} app && \ apt-get update && \ apt-get install -y --no-install-recommends wait-for-it dumb-init curl && \ (curl -sSL https://install.python-poetry.org | python -) && \ python3.10 -m venv ${VIRTUAL_ENV} && \ mkdir /srv/app /srv/bin /srv/lib /srv/log /srv/run && \ chown -R ${APP_USER_UID}:${APP_USER_GID} /srv ENV PATH="${VIRTUAL_ENV}/bin:/srv/bin:/srv/poetry/bin:${PATH}" USER app WORKDIR /srv/app FROM base AS development ARG APP_USER_UID ARG APP_USER_GID ARG IMAGE_TAG USER app WORKDIR /srv/app FROM development AS deployment-build ARG APP_USER_UID ARG APP_USER_GID ARG IMAGE_TAG ADD --chown=$APP_USER_UID:$APP_USER_GID . /srv/app RUN poetry install --no-dev FROM deployment-build AS ci ARG APP_USER_UID ARG APP_USER_GID ARG IMAGE_TAG RUN poetry install FROM base AS deployment ARG APP_USER_UID ARG APP_USER_GID ARG IMAGE_TAG COPY --from=deployment-build /srv/app /srv/app COPY --from=deployment-build /srv/venv /srv/venv RUN chown -R $APP_USER_UID:$APP_USER_GID /srv USER root RUN apt-get clean autoclean && \ apt-get autoremove --yes && \ rm -rf /var/lib/apt /var/lib/dpkg && \ rm -rf /home/app/.cache USER app ENV PYTHONPATH="/srv/app" ENV DJANGO_SETTINGS_MODULE="settings" EXPOSE 8000 ENTRYPOINT ["/usr/bin/dumb-init"] CMD ["echo NOOP"]