Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,25 @@ RUN apt-get update && apt-get install -y \
WORKDIR /app

# Copy just the dependency files first, for more efficient layer caching
COPY pyproject.toml uv.lock ./
RUN mkdir -p src
COPY --chown=appuser:appuser pyproject.toml uv.lock ./
RUN mkdir -p src && chown -R appuser:appuser /app

# Install Python dependencies using UV's lock file
# --locked ensures we use exact versions from uv.lock for reproducible builds
# This creates a virtual environment and installs all dependencies
# Ensure your uv.lock file is checked in for consistency across environments
# Switch to appuser before installing to avoid needing chown later
USER appuser
RUN uv sync --locked

# Switch back to root to copy files, then set ownership
USER root

# Copy all remaining application files into the container
# This includes source code, configuration files, and dependency specifications
# (Excludes files specified in .dockerignore)
COPY . .

# Change ownership of all app files to the non-privileged user
# This ensures the application can read/write files as needed
RUN chown -R appuser:appuser /app
# Using --chown to set ownership during copy (much faster than chown -R later)
COPY --chown=appuser:appuser . .

# Switch to the non-privileged user for all subsequent operations
# This improves security by not running as root
Expand Down