forked from modmail-dev/Modmail
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the slim-bookworm image, refactored some steps
- Loading branch information
Showing
1 changed file
with
26 additions
and
26 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,38 +1,38 @@ | ||
FROM python:3.11-alpine as base | ||
|
||
RUN apk add --no-cache \ | ||
# cairosvg dependencies | ||
cairo-dev cairo cairo-tools \ | ||
# pillow dependencies | ||
jpeg-dev zlib-dev \ | ||
&& adduser -D -h /home/modmail -g 'Modmail' modmail | ||
|
||
ENV VIRTUAL_ENV=/home/modmail/.venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
WORKDIR /home/modmail | ||
FROM python:3.11-slim-bookworm as base | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
# Install CairoSVG dependencies. | ||
libcairo2 && \ | ||
# Cleanup APT. | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
# Create a non-root user. | ||
useradd --create-home -d /opt/modmail modmail | ||
|
||
FROM base as builder | ||
|
||
RUN apk add build-base libffi-dev | ||
COPY requirements.txt . | ||
|
||
RUN python -m venv $VIRTUAL_ENV | ||
RUN pip install --root-user-action=ignore --no-cache-dir --upgrade pip wheel && \ | ||
python -m venv /opt/modmail/.venv && \ | ||
. /opt/modmail/.venv/bin/activate && \ | ||
pip install --no-cache-dir --upgrade -r requirements.txt | ||
|
||
COPY --chown=modmail:modmail requirements.txt . | ||
RUN pip install --upgrade pip setuptools && \ | ||
pip install -r requirements.txt | ||
FROM base | ||
|
||
FROM base as runtime | ||
|
||
# copy the entire venv | ||
COPY --from=builder --chown=modmail:modmail $VIRTUAL_ENV $VIRTUAL_ENV | ||
# Copy the entire venv. | ||
COPY --from=builder --chown=modmail:modmail /opt/modmail/.venv /opt/modmail/.venv | ||
|
||
# copy repository files | ||
WORKDIR /opt/modmail | ||
USER modmail:modmail | ||
COPY --chown=modmail:modmail . . | ||
|
||
# this disables the internal auto-update | ||
ENV USING_DOCKER yes | ||
|
||
USER modmail | ||
# This sets some Python runtime variables and disables the internal auto-update. | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PATH=/opt/modmail/.venv/bin:$PATH \ | ||
USING_DOCKER=yes | ||
|
||
CMD ["python", "bot.py"] |