Refactor Dockerfile to minimize image size
All checks were successful
Test code; build Docker image; push to Docker Hub, GitHub Container Registry and Gitea. / test (push) Successful in 2m31s
All checks were successful
Test code; build Docker image; push to Docker Hub, GitHub Container Registry and Gitea. / test (push) Successful in 2m31s
This commit is contained in:
24
Dockerfile
24
Dockerfile
@ -1,23 +1,25 @@
|
|||||||
FROM python:3.13-slim
|
# syntax=docker/dockerfile:1
|
||||||
|
# check=error=true;experimental=all
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM ghcr.io/jrottenberg/ffmpeg:7.1-scratch
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
|
|
||||||
RUN apt-get update && apt-get install ffmpeg -y --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV UV_LINK_MODE=copy
|
||||||
|
ENV UV_NO_CACHE=1
|
||||||
|
|
||||||
RUN useradd --create-home botuser && mkdir /Uploads && chown botuser:botuser /Uploads
|
RUN apk add --no-cache shadow python3 && useradd --create-home botuser && mkdir /Uploads && chown botuser:botuser /Uploads
|
||||||
USER botuser
|
USER botuser
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ADD --chown=botuser:botuser discord_embed /app/discord_embed
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
uv sync --no-install-project --no-dev
|
||||||
uv sync --no-install-project
|
|
||||||
|
|
||||||
COPY --chown=botuser:botuser discord_embed /app/discord_embed
|
|
||||||
|
|
||||||
VOLUME ["/Uploads"]
|
VOLUME ["/Uploads"]
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
|
||||||
|
|
||||||
CMD ["uv", "run", "uvicorn", "discord_embed.main:app", "--host", "0.0.0.0", "--port", "5000", "--use-colors", "--proxy-headers", "--forwarded-allow-ips", "*", "--log-level", "debug"]
|
CMD ["uv", "run", "uvicorn", "discord_embed.main:app", "--host", "0.0.0.0", "--port", "5000", "--use-colors", "--proxy-headers", "--forwarded-allow-ips", "*", "--log-level", "debug"]
|
||||||
|
Reference in New Issue
Block a user