|
1 | | -FROM python:3.12-slim |
| 1 | +ARG PYTHON_BASE=3.13-slim-bookworm |
| 2 | +ARG UV_BASE=python3.13-bookworm-slim |
2 | 3 |
|
3 | | -LABEL org.opencontainers.image.source=https://github.com/pythonistaguild/mystbin |
4 | | -LABEL org.opencontainers.image.description="Container for running MystB.in" |
5 | | -LABEL org.opencontainers.image.licenses=GPLv3 |
6 | | - |
7 | | -RUN mkdir -p /etc/apt/keyrings \ |
8 | | - && apt update -y \ |
9 | | - && apt-get install --no-install-recommends -y \ |
10 | | - # deps for building python deps |
11 | | - git \ |
12 | | - build-essential \ |
13 | | - libcurl4-gnutls-dev \ |
14 | | - gnutls-dev \ |
15 | | - libmagic-dev \ |
| 4 | +FROM ghcr.io/astral-sh/uv:${UV_BASE} AS builder |
| 5 | + |
| 6 | +ENV UV_PYTHON_DOWNLOADS=0 |
| 7 | + |
| 8 | +WORKDIR /project |
| 9 | + |
| 10 | +# install latest git |
| 11 | +RUN apt-get update -y \ |
| 12 | + && apt-get upgrade -y \ |
| 13 | + && apt-get install --no-install-recommends --no-install-suggests -y git \ |
16 | 14 | && rm -rf /var/lib/apt/lists/* |
17 | 15 |
|
18 | | -# copy project requirement files here to ensure they will be cached. |
| 16 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 17 | + --mount=type=bind,source=pyproject.toml,target=/project/pyproject.toml \ |
| 18 | + --mount=type=bind,source=uv.lock,target=/project/uv.lock \ |
| 19 | + uv sync --frozen --no-install-project --no-dev |
| 20 | + |
| 21 | +ADD --chown=1000:1000 . /project |
| 22 | + |
| 23 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 24 | + uv sync --frozen --no-install-project --no-dev |
| 25 | + |
| 26 | +FROM python:${PYTHON_BASE} |
| 27 | + |
| 28 | +LABEL org.opencontainers.image.source=https://github.com/pythonistaguild/mystbin |
| 29 | +LABEL org.opencontainers.image.description="A paste service built for simplicity and beauty" |
| 30 | + |
| 31 | +USER 1000:1000 |
| 32 | + |
19 | 33 | WORKDIR /app |
20 | | -COPY requirements.txt ./ |
21 | 34 |
|
22 | | -# install runtime deps |
23 | | -RUN pip install -Ur requirements.txt |
| 35 | +COPY --from=builder --chown=1000:1000 /project /app |
| 36 | +ENV PATH="/app/.venv/bin:$PATH" |
24 | 37 |
|
25 | | -COPY . /app/ |
26 | | -ENTRYPOINT python -O launcher.py |
| 38 | +CMD ["python", "-O", "launcher.py"] |
0 commit comments