69 lines
1.9 KiB
Docker
69 lines
1.9 KiB
Docker
FROM ghcr.io/astral-sh/uv:python3.13-alpine
|
|
|
|
ENV PUID=1000
|
|
ENV PGID=1000
|
|
ENV GOSU_VERSION=1.17
|
|
|
|
RUN apk add --no-cache tini dos2unix
|
|
|
|
# Install gosu
|
|
RUN set -eux; \
|
|
\
|
|
apk add --no-cache --virtual .gosu-deps \
|
|
ca-certificates \
|
|
dpkg \
|
|
gnupg \
|
|
; \
|
|
\
|
|
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
|
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
|
|
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
|
|
\
|
|
# verify the signature
|
|
export GNUPGHOME="$(mktemp -d)"; \
|
|
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
|
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
|
gpgconf --kill all; \
|
|
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
|
|
\
|
|
# clean up fetch dependencies
|
|
apk del --no-network .gosu-deps; \
|
|
\
|
|
chmod +x /usr/local/bin/gosu; \
|
|
# verify that the binary works
|
|
gosu --version; \
|
|
gosu nobody true
|
|
|
|
WORKDIR /app
|
|
|
|
# Enable bytecode compilation
|
|
ENV UV_COMPILE_BYTECODE=1
|
|
|
|
ENV UV_LINK_MODE=copy
|
|
|
|
# Set the cache directory to /tmp instead of root
|
|
ENV UV_CACHE_DIR=/tmp/.cache/uv
|
|
|
|
# Install the project's dependencies using the lockfile and settings
|
|
RUN --mount=type=cache,target=/tmp/.cache/uv \
|
|
--mount=type=bind,source=uv.lock,target=uv.lock \
|
|
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
|
uv sync --frozen --no-install-project --no-dev
|
|
|
|
# Then, add the rest of the project source code and install it
|
|
# Installing separately from its dependencies allows optimal layer caching
|
|
COPY . /app
|
|
RUN --mount=type=cache,target=/tmp/.cache/uv \
|
|
uv sync --frozen --no-dev
|
|
|
|
# Place executables in the environment at the front of the path
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
|
COPY . .
|
|
|
|
RUN chmod +x *.sh && \
|
|
dos2unix *.sh
|
|
|
|
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
|
CMD ["python", "-u", "main.py"]
|