From 65a69319c154b6a189e13509c3fbb0aebbfe4fb0 Mon Sep 17 00:00:00 2001 From: Raiden Sakura Date: Wed, 10 Apr 2024 19:53:03 +0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96a398fad4..8316d6139b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,38 @@ -FROM python:3.10 as py +FROM python:3.11-alpine as base -FROM py as build +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 -RUN apt update && apt install -y g++ git +ENV VIRTUAL_ENV=/home/modmail/.venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" -COPY requirements.txt / -RUN pip install --prefix=/inst -U -r /requirements.txt +WORKDIR /home/modmail -FROM py +FROM base as builder -COPY --from=build /inst /usr/local +RUN apk add build-base libffi-dev +RUN python -m venv $VIRTUAL_ENV + +COPY --chown=modmail:modmail requirements.txt . +RUN pip install --upgrade pip setuptools && \ + pip install -r requirements.txt + +FROM base as runtime + +# copy the entire venv +COPY --from=builder --chown=modmail:modmail $VIRTUAL_ENV $VIRTUAL_ENV + +# copy repository files +COPY --chown=modmail:modmail . . + +# this disables the internal auto-update ENV USING_DOCKER yes -RUN useradd --system --no-create-home modmail + USER modmail -WORKDIR /modmailbot CMD ["python", "bot.py"] -COPY --chown=modmail:modmail . /modmailbot