fix: now hurl test and update Dockerfile
All checks were successful
Check Code Quality / RuffCheck (push) Successful in 2m13s
Build Docker / BuildImage (push) Successful in 2m44s

This commit is contained in:
2026-03-21 15:45:53 +11:00
parent ce956abe5c
commit 6f693e58f7
2 changed files with 32 additions and 36 deletions

View File

@@ -4,6 +4,7 @@
FROM python:3.13-alpine AS build FROM python:3.13-alpine AS build
# Install build dependencies for Pillow and other native wheels # Install build dependencies for Pillow and other native wheels
# Kept in case source builds are needed, though wheels are preferred
RUN apk add --no-cache \ RUN apk add --no-cache \
build-base \ build-base \
jpeg-dev zlib-dev freetype-dev jpeg-dev zlib-dev freetype-dev
@@ -12,51 +13,46 @@ RUN apk add --no-cache \
COPY --from=ghcr.io/astral-sh/uv:0.8.21 /uv /uvx /bin/ COPY --from=ghcr.io/astral-sh/uv:0.8.21 /uv /uvx /bin/
WORKDIR /app WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./ COPY pyproject.toml uv.lock ./
# Install dependencies into a virtual environment # Install dependencies into a virtual environment
# - --frozen: strict lockfile usage
# - --no-dev: exclude development dependencies
# - --no-install-project: avoid installing app as package
# - --compile-bytecode: ensuring .pyc files for startup speed (optional, omit if size is critical but usually worth it)
# We omit --compile-bytecode here to save space as requested
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
# Copy only app source files uv sync --frozen --no-dev --no-install-workspace
COPY blueprints blueprints
COPY main.py server.py curl.py tools.py mail.py cache_helper.py ascii_art.py ./
COPY templates templates
COPY data data
COPY pwa pwa
COPY .well-known .well-known
# Clean up caches and pycache
RUN rm -rf /root/.cache/uv
RUN find . -type d -name "__pycache__" -exec rm -rf {} +
### Runtime stage ### ### Runtime stage ###
FROM python:3.13-alpine AS runtime FROM python:3.13-alpine AS runtime
ENV PATH="/app/.venv/bin:$PATH" ENV PATH="/app/.venv/bin:$PATH"
# Create non-root user # Create non-root user and install curl for healthchecks
RUN addgroup -g 1001 appgroup && \ RUN addgroup -g 1001 appgroup && \
adduser -D -u 1001 -G appgroup -h /app appuser adduser -D -u 1001 -G appgroup -h /app appuser && \
apk add --no-cache curl
WORKDIR /app WORKDIR /app
RUN apk add --no-cache curl
# Copy the virtual environment from build stage
# Copy only whats needed for runtime
COPY --from=build --chown=appuser:appgroup /app/.venv /app/.venv COPY --from=build --chown=appuser:appgroup /app/.venv /app/.venv
COPY --from=build --chown=appuser:appgroup /app/blueprints /app/blueprints
COPY --from=build --chown=appuser:appgroup /app/templates /app/templates # Copy all top-level Python files
COPY --from=build --chown=appuser:appgroup /app/data /app/data COPY --chown=appuser:appgroup *.py ./
COPY --from=build --chown=appuser:appgroup /app/pwa /app/pwa
COPY --from=build --chown=appuser:appgroup /app/.well-known /app/.well-known # Copy application directories
COPY --from=build --chown=appuser:appgroup /app/main.py /app/ COPY --chown=appuser:appgroup blueprints blueprints
COPY --from=build --chown=appuser:appgroup /app/server.py /app/ COPY --chown=appuser:appgroup templates templates
COPY --from=build --chown=appuser:appgroup /app/curl.py /app/ COPY --chown=appuser:appgroup data data
COPY --from=build --chown=appuser:appgroup /app/tools.py /app/ COPY --chown=appuser:appgroup pwa pwa
COPY --from=build --chown=appuser:appgroup /app/mail.py /app/ COPY --chown=appuser:appgroup .well-known .well-known
COPY --from=build --chown=appuser:appgroup /app/cache_helper.py /app/
COPY --from=build --chown=appuser:appgroup /app/ascii_art.py /app/
USER appuser USER appuser
EXPOSE 5000 EXPOSE 5000

View File

@@ -10,15 +10,15 @@ HTTP 200
GET http://127.0.0.1:5000/now/24_02_18 GET http://127.0.0.1:5000/now/24_02_18
HTTP 200 HTTP 200
GET http://127.0.0.1:5000/now/now.json GET http://127.0.0.1:5000/now.json
HTTP 200 HTTP 200
GET http://127.0.0.1:5000/now/now.xml GET http://127.0.0.1:5000/now.xml
HTTP 200 HTTP 200
GET http://127.0.0.1:5000/now/now.rss GET http://127.0.0.1:5000/now.rss
HTTP 200 HTTP 200
GET http://127.0.0.1:5000/now/rss.xml GET http://127.0.0.1:5000/rss.xml
HTTP 200 HTTP 200