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

Optimize Docker build #206

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM python:3.10 AS build
ENV POETRY_VIRTUALENVS_CREATE false
RUN curl -sSL https://install.python-poetry.org | python -
COPY . /src
WORKDIR /src
RUN $HOME/.local/bin/poetry install --only main
# Install dependencies separately from the package itself. Assuming that the
# requirements change less frequently than the code, this will result in more
# efficient caching of container layers.

FROM python:3.12 AS requirements
RUN pip install --no-cache-dir poetry poetry-plugin-export
COPY pyproject.toml poetry.lock /
RUN poetry export | pip install --no-cache-dir --ignore-installed --root /destdir -r /dev/stdin

FROM python:3.10-slim
COPY --from=build /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
COPY --from=build /src/ /src/
COPY --from=build /usr/local/bin/gcn-email /usr/local/bin/
FROM python:3.12-slim
COPY --from=requirements /destdir /
COPY . /src
RUN pip install --no-cache-dir --no-deps --editable /src
ENTRYPOINT ["gcn-email"]
USER nobody:nogroup