feat: update dockerfile

This commit is contained in:
Christian Groschupp 2025-03-28 10:04:17 +01:00
parent 87276d9432
commit 11d3079dbd
5 changed files with 26 additions and 47 deletions

View File

@ -6,6 +6,7 @@ __pycache__/
# Ignore virtual environments # Ignore virtual environments
venv/ venv/
.env/ .env/
.venv
# Ignore test files and directories # Ignore test files and directories
tests/ tests/
@ -31,3 +32,6 @@ Dockerfile*
# Images # Images
*.png *.png
# Ignore caches
.*cache

View File

@ -1,54 +1,32 @@
FROM python:3.10-alpine AS builder ARG PYTHON_VERSION=3.13
FROM ghcr.io/astral-sh/uv:0.6-python${PYTHON_VERSION}-alpine AS builder
WORKDIR /app
RUN apk add --no-cache postgresql-dev
COPY uv.lock .
COPY pyproject.toml .
RUN uv sync --no-dev
FROM python:${PYTHON_VERSION}-alpine
WORKDIR /app WORKDIR /app
RUN apk add --no-cache \ RUN apk add --no-cache postgresql-libs
postgresql-dev \
gcc \
musl-dev \
libffi-dev \
curl \
g++ \
make \
libxml2-dev \
libxslt-dev \
tzdata
RUN pip install --no-cache-dir poetry
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock ./
RUN poetry install --only main --no-interaction --no-ansi --no-root
FROM python:3.10-alpine
WORKDIR /app
RUN apk add --no-cache \
postgresql-libs \
libffi \
libxml2 \
libxslt \
tzdata \
curl
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \ ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8 \ SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8
SUPERCRONIC=supercronic-linux-amd64
RUN curl -fsSLO "$SUPERCRONIC_URL" \ RUN wget -qO /usr/local/bin/supercronic "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && echo "${SUPERCRONIC_SHA1SUM} /usr/local/bin/supercronic" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \ && chmod +x /usr/local/bin/supercronic
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10 COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app /app
ENV PYTHONPATH=/usr/local/lib/python3.10/site-packages ENV PATH=/app/.venv/bin:$PATH
COPY . . COPY . .
CMD echo "${CRON:-0 0 * * *} python /app/cleanmedia.py ${CLEANMEDIA_OPTS:-c /etc/dendrite/dendrite.yaml -t 30 -n -l}" > /app/crontab && \ CMD echo "${CRON:-0 0 * * *} /app/cleanmedia.py ${CLEANMEDIA_OPTS:-c /etc/dendrite/dendrite.yaml -t 30 -n -l}" > /app/crontab && \
/usr/local/bin/supercronic /app/crontab /usr/local/bin/supercronic /app/crontab

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
"""Media cleanup utility for Dendrite servers.""" """Media cleanup utility for Dendrite servers."""
""" """

View File

@ -26,10 +26,6 @@ dev = [
"pytest-coverage>=0.0,<0.1", "pytest-coverage>=0.0,<0.1",
] ]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.mypy] [tool.mypy]
ignore_missing_imports = true ignore_missing_imports = true
strict = true strict = true

2
uv.lock generated
View File

@ -37,7 +37,7 @@ wheels = [
[[package]] [[package]]
name = "cleanmedia" name = "cleanmedia"
version = "0.1.0" version = "0.1.0"
source = { editable = "." } source = { virtual = "." }
dependencies = [ dependencies = [
{ name = "psycopg2" }, { name = "psycopg2" },
{ name = "pyyaml" }, { name = "pyyaml" },