Skip to content

Commit

Permalink
optimize image size
Browse files Browse the repository at this point in the history
  • Loading branch information
dpr-0 committed Jun 18, 2022
1 parent 8c85f18 commit 5c27577
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# syntax=docker/dockerfile:1
FROM python:3.10-slim-buster
FROM python:3.10.5-slim-bullseye as builder

WORKDIR /app
COPY makefile bot.py pyproject.toml ./
COPY pyproject.toml ./

RUN python -m venv --copies venv
ENV PATH="/app/venv/bin:$PATH"

RUN pip install "poetry==1.1.13" --no-cache-dir && \
poetry config virtualenvs.create false && \
poetry install --no-dev --no-root --no-interaction --no-ansi && \
pip uninstall --yes poetry && \
pip cache purge && \
rm -rf ~/.cache/pypoetry/{cache,artifacts}

FROM python:3.10.5-slim-bullseye as prod

COPY --from=builder /app/venv app/venv
ENV PATH="/app/venv/bin:$PATH"

WORKDIR /app
COPY bot.py ./
COPY hnread ./hnread
RUN pip install "poetry==1.1.13" --no-cache-dir \
&& poetry config virtualenvs.create false \
&& poetry install --no-dev --no-root --no-interaction --no-ansi \
&& rm -rf ~/.cache/pypoetry/{cache,artifacts}

CMD ["python", "bot.py"]

0 comments on commit 5c27577

Please sign in to comment.