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 Dockerfile #1679

Merged
merged 2 commits into from
Jul 5, 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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fixes:
- chore: bump jinja to 3.1.3 (#1684)
- chore: bump actions/setup-python version (#1686)
- chore: bump actions/checkout version (#1696)
- chore: optimize Dockerfile (#1679)

v6.2.0 (2024-01-01)
-------------------
Expand Down
36 changes: 17 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
ARG BASE_IMAGE=python:3.9-slim
ARG INSTALL_EXTRAS=irc,XMPP,telegram,slack

FROM ${BASE_IMAGE} AS build
FROM python:3.9 AS build
ARG INSTALL_EXTRAS

WORKDIR /wheel

COPY . .
RUN apt update && apt install -y build-essential git
RUN pip3 wheel --wheel-dir=/wheel \
wheel . .[${INSTALL_EXTRAS}]
RUN pip wheel --wheel-dir=/wheel wheel . .[${INSTALL_EXTRAS}]

FROM ${BASE_IMAGE} AS base
FROM python:3.9-slim
ARG INSTALL_EXTRAS
COPY --from=build /wheel /wheel
RUN apt update && \
apt install -y git && \
cd /wheel && \
pip3 -vv install --no-cache-dir --no-index --find-links /wheel \
errbot errbot[${INSTALL_EXTRAS}] && \
rm -rf /wheel /var/lib/apt/lists/*
RUN useradd -m errbot

FROM base
EXPOSE 3141 3142
VOLUME /home/errbot
WORKDIR /home/errbot

RUN --mount=from=build,source=/wheel,target=/wheel \
pip install --no-cache-dir --no-index --find-links /wheel \
errbot errbot[${INSTALL_EXTRAS}]

RUN useradd --create-home --shell /bin/bash errbot
USER errbot
WORKDIR /home/errbot

RUN errbot --init

EXPOSE 3141 3142
VOLUME /home/errbot
STOPSIGNAL SIGINT

ENTRYPOINT [ "/usr/local/bin/errbot" ]