File tree Expand file tree Collapse file tree 1 file changed +30
-12
lines changed Expand file tree Collapse file tree 1 file changed +30
-12
lines changed Original file line number Diff line number Diff line change 1- FROM python:3.10 as py
1+ FROM python:3.11-slim-bookworm as base
22
3- FROM py as build
3+ RUN apt-get update && \
4+ apt-get install --no-install-recommends -y \
5+ # Install CairoSVG dependencies.
6+ libcairo2 && \
7+ # Cleanup APT.
8+ apt-get clean && \
9+ rm -rf /var/lib/apt/lists/* && \
10+ # Create a non-root user.
11+ useradd --shell /usr/sbin/nologin --create-home -d /opt/modmail modmail
412
5- RUN apt update && apt install -y g++ git
13+ FROM base as builder
614
7- COPY requirements.txt /
8- RUN pip install --prefix=/inst -U -r /requirements.txt
15+ COPY requirements.txt .
916
10- FROM py
17+ RUN pip install --root-user-action=ignore --no-cache-dir --upgrade pip wheel && \
18+ python -m venv /opt/modmail/.venv && \
19+ . /opt/modmail/.venv/bin/activate && \
20+ pip install --no-cache-dir --upgrade -r requirements.txt
1121
12- COPY --from=build /inst /usr/local
22+ FROM base
1323
14- ENV USING_DOCKER yes
15- RUN useradd --system --no-create-home modmail
16- USER modmail
24+ # Copy the entire venv.
25+ COPY --from=builder --chown=modmail:modmail /opt/modmail/.venv /opt/modmail/.venv
26+
27+ # Copy repository files.
28+ WORKDIR /opt/modmail
29+ USER modmail:modmail
30+ COPY --chown=modmail:modmail . .
31+
32+ # This sets some Python runtime variables and disables the internal auto-update.
33+ ENV PYTHONUNBUFFERED=1 \
34+ PYTHONDONTWRITEBYTECODE=1 \
35+ PATH=/opt/modmail/.venv/bin:$PATH \
36+ USING_DOCKER=yes
1737
18- WORKDIR /modmailbot
1938CMD ["python" , "bot.py" ]
20- COPY --chown=modmail:modmail . /modmailbot
You can’t perform that action at this time.
0 commit comments