Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 and bump to Debian Bookworm w/ multi-stage build #318

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.1
3.11.9
40 changes: 26 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
FROM python:3.10-slim-bullseye
# Stage 1: Build
FROM python:3.11-slim-bookworm as builder

EXPOSE 9808
ENV PYTHONUNBUFFERED 1
ENV PYTHONUNBUFFERED=1 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app/
COPY pyproject.toml poetry.lock /app/
RUN apt-get update && \
apt-get -y dist-upgrade && \
apt install -y locales libcurl4-openssl-dev libssl-dev build-essential\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U pip poetry \
&& rm -rf /root/.cache \
&& poetry config virtualenvs.create false \
&& poetry install --no-interaction \
&& rm -rf /root/.cache \
&& apt remove -y build-essential \
&& adduser --disabled-login exporter
apt install -y locales libcurl4-openssl-dev libssl-dev build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip install -U pip poetry && \
poetry install --without dev --no-root && \
rm -rf $POETRY_CACHE_DIR

USER exporter
# Stage 2: Runtime environment
FROM python:3.11-slim-bookworm

ENV PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY . /app/

EXPOSE 9808

RUN adduser --disabled-login exporter

USER exporter

ENTRYPOINT ["python", "/app/cli.py"]
Loading