k8s-pulse/Dockerfile

38 lines
1.1 KiB
Docker
Raw Normal View History

# Stage 1: Build
FROM cgr.dev/chainguard/python:latest-dev AS builder
2026-07-24 00:15:19 +00:00
# Set build directory
2026-07-24 00:15:19 +00:00
WORKDIR /app
# Copy project files and ensure they are owned by the nonroot user (65532)
COPY --chown=65532:65532 . .
# Create a virtual environment and install dependencies
# We use a relative path 'venv' to stay within the writable /app directory.
RUN python -m venv venv
ENV PATH="/app/venv/bin:$PATH"
2026-07-24 00:15:19 +00:00
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Runtime
FROM cgr.dev/chainguard/python:latest
# Set environment variables
ENV PATH="/app/venv/bin:$PATH"
# In distroless-style images, we don't have a shell, so we must be explicit.
ENV PYTHONUNBUFFERED=1
# Work in the standard /app directory
WORKDIR /app
# Copy virtual environment and application files from builder
# We use --chown to ensure the runtime user (nonroot/65532) can access the files.
COPY --from=builder --chown=65532:65532 /app /app
2026-07-24 00:15:19 +00:00
# Expose port
2026-07-24 00:15:19 +00:00
EXPOSE 5000
# Run gunicorn using the virtual environment's python directly or gunicorn binary.
ENTRYPOINT ["/app/venv/bin/gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
2026-07-24 11:17:10 +00:00
#harbor.freshbrewed.science/library/k8s-pulse