@@ -3,52 +3,56 @@ FROM python:3.12-bullseye AS python-base
33# python
44# ENV variables are also available in the later build stages
55ENV PYTHONUNBUFFERED=1 \
6- # prevents python creating .pyc files
7- PYTHONDONTWRITEBYTECODE=1 \
8- \
9- # pip
10- PIP_NO_CACHE_DIR=off \
11- PIP_DISABLE_PIP_VERSION_CHECK=on \
12- PIP_DEFAULT_TIMEOUT=100 \
13- \
14- # poetry
15- # https://python-poetry.org/docs/#installing-with-the-official-installer
16- # https://python-poetry.org/docs/configuration/#using-environment-variables
17- POETRY_VERSION=1.8.3 \
18- # make poetry install to this location
19- POETRY_HOME="/opt/poetry" \
20- # make poetry create the virtual environment in the project's root
21- # it gets named `.venv`
22- POETRY_VIRTUALENVS_IN_PROJECT=true \
23- # do not ask any interactive question
24- POETRY_NO_INTERACTION=1 \
25- \
26- # paths
27- # this is where our requirements + virtual environment will live
28- PYSETUP_PATH="/opt/pysetup" \
29- VENV_PATH="/opt/pysetup/.venv"
6+ # prevents python creating .pyc files
7+ PYTHONDONTWRITEBYTECODE=1 \
8+ \
9+ # pip
10+ PIP_NO_CACHE_DIR=off \
11+ PIP_DISABLE_PIP_VERSION_CHECK=on \
12+ PIP_DEFAULT_TIMEOUT=100 \
13+ \
14+ # poetry
15+ # https://python-poetry.org/docs/#installing-with-the-official-installer
16+ # https://python-poetry.org/docs/configuration/#using-environment-variables
17+ POETRY_VERSION=1.8.3 \
18+ # make poetry install to this location
19+ POETRY_HOME="/opt/poetry" \
20+ # make poetry create the virtual environment in the project's root
21+ # it gets named `.venv`
22+ POETRY_VIRTUALENVS_IN_PROJECT=true \
23+ # do not ask any interactive question
24+ POETRY_NO_INTERACTION=1 \
25+ \
26+ # paths
27+ # this is where our requirements + virtual environment will live
28+ PYSETUP_PATH="/opt/pysetup" \
29+ VENV_PATH="/opt/pysetup/.venv"
3030
3131# prepend poetry and venv to path
3232ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
3333
3434# deps for db management commands and transferring to an archive
3535# make sure to match the postgres version to the service in the compose file
3636RUN apt-get update \
37- && apt-get install --no-install-recommends -y postgresql-common \
38- && /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
39- && apt-get install --no-install-recommends -y \
40- postgresql-client-17 \
41- p7zip-full
37+ && apt-get install --no-install-recommends -y \
38+ postgresql-common \
39+ && /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
40+ && apt-get install --no-install-recommends -y \
41+ postgresql-client-17 \
42+ p7zip-full \
43+ && rm -rf /var/lib/apt/lists/*
4244
4345
4446# `builder-base` stage is used to build deps + create our virtual environment
4547FROM python-base AS builder-base
48+
4649RUN apt-get update \
47- && apt-get install --no-install-recommends -y \
48- # deps for installing poetry
49- curl \
50- # deps for building python deps
51- build-essential
50+ && apt-get install --no-install-recommends -y \
51+ # deps for installing poetry
52+ curl \
53+ # deps for building python deps
54+ build-essential \
55+ && rm -rf /var/lib/apt/lists/*
5256
5357# install poetry - respects $POETRY_VERSION & $POETRY_HOME
5458RUN curl -sSL https://install.python-poetry.org | python3 -
@@ -63,6 +67,7 @@ RUN poetry install --without dev
6367
6468# `development` image is used during development / testing
6569FROM python-base AS development
70+
6671WORKDIR $PYSETUP_PATH
6772
6873# copy in our built poetry + venv
0 commit comments