|
| 1 | +# NOTE: Why not Alpine? Because Alpine demands installation of OS software |
| 2 | +# prior to running app code, which leads to maintenance work and a larger image |
| 3 | +# size compared to Debian — considering Debian layers are shared across images. |
| 4 | +FROM python:3.12 |
| 5 | + |
| 6 | +# Prevent Python from buffering stdout and stderr |
| 7 | +# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED |
| 8 | +ENV PYTHONUNBUFFERED=1 |
| 9 | + |
| 10 | +# Prevent Python from writing .pyc files to disk |
| 11 | +# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE |
| 12 | +ENV PYTHONDONTWRITEBYTECODE=1 |
| 13 | + |
| 14 | +# Install Python packages |
| 15 | +# NOTE: Forcefully delete optional private dependencies for now since Poetry |
| 16 | +# needs to fetch them in order to calculate the dependency tree. |
| 17 | +# See https://github.com/python-poetry/poetry/issues/4562 |
| 18 | +# TODO: Improve management of enterprise features |
| 19 | +WORKDIR /tmp |
| 20 | +ARG POETRY_VERSION_CONSTRAINT |
| 21 | +ARG INSTALL_DEV |
| 22 | +COPY api/pyproject.toml . |
| 23 | +RUN \ |
| 24 | + pip install --no-cache-dir poetry${POETRY_VERSION_CONSTRAINT:-} &&\ |
| 25 | + poetry config virtualenvs.create false &&\ |
| 26 | + poetry config cache-dir /var/cache/pypoetry &&\ |
| 27 | + sed -ie '/tool.poetry.group.auth-controller/,+1d' pyproject.toml &&\ |
| 28 | + sed -ie '/tool.poetry.group.saml/,+1d' pyproject.toml &&\ |
| 29 | + sed -ie '/tool.poetry.group.ldap/,+1d' pyproject.toml &&\ |
| 30 | + sed -ie '/tool.poetry.group.workflows/,+1d' pyproject.toml &&\ |
| 31 | + sed -ie '/tool.poetry.group.licensing/,+1d' pyproject.toml &&\ |
| 32 | + poetry install --no-root $([ "${INSTALL_DEV}" = "true" ] && echo --with dev) |
| 33 | + |
| 34 | +# Prepare the app |
| 35 | +WORKDIR /app |
| 36 | +COPY api/ . |
| 37 | +EXPOSE 8000 |
| 38 | +CMD ["flagsmith", "start", "api"] |
0 commit comments