-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use --mount instead of COPY to reduce image size
- Loading branch information
1 parent
eb51a93
commit d4a52fe
Showing
1 changed file
with
17 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |