-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (41 loc) · 1.48 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Multi-stage Docker build for sonarr-metadata-rewrite using uv
# Build arg for Python version
ARG PYTHON_VERSION=3.14
# Build stage
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-trixie-slim AS builder
# Set environment variables for optimal uv behavior
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
# Create app directory
WORKDIR /app
# Copy uv configuration files
COPY pyproject.toml uv.lock ./
# Install dependencies into a virtual environment
RUN uv sync --frozen --no-install-project --no-dev
# Copy and install the pre-built wheel into the existing venv
COPY dist/*.whl /tmp/
RUN uv pip install /tmp/*.whl --no-deps
# Runtime stage
FROM python:${PYTHON_VERSION}-slim-trixie AS runtime
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PATH="/app/.venv/bin:$PATH"
# Create non-root user
RUN groupadd --gid 1000 app && \
useradd --uid 1000 --gid app --shell /bin/bash --create-home app
# Copy virtual environment from builder stage
COPY --from=builder --chown=app:app /app/.venv /app/.venv
# Create directories for the application
RUN mkdir -p /app/data && chown -R app:app /app
# Switch to non-root user
USER app
# Set working directory
WORKDIR /app
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sonarr_metadata_rewrite" || exit 1
# Expose any ports if needed (none for this application)
# EXPOSE 8080
# Set the entry point to the CLI command
ENTRYPOINT ["sonarr-metadata-rewrite"]