Skip to content

Commit

Permalink
fix: docker build (#3621)
Browse files Browse the repository at this point in the history
* feat: add repository credentials as inputs for build-image action

* feat: optimize Dockerfile by adding multi-stage build for improved image size
  • Loading branch information
derkweijers authored Nov 18, 2024
1 parent cc14fe4 commit 561b279
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim as builder

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# Get the required UV tokens for the project
ARG UV_INDEX_TSD_USERNAME
Expand All @@ -8,15 +8,24 @@ ARG UV_INDEX_TSD_PASSWORD
ENV UV_INDEX_TSD_USERNAME=$UV_INDEX_TSD_USERNAME
ENV UV_INDEX_TSD_PASSWORD=$UV_INDEX_TSD_PASSWORD

Check warning on line 9 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "UV_INDEX_TSD_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

# Update the package os dependencies
RUN apt-get update && apt-get install -y
WORKDIR /app

# Copy the project files into the image
ADD pyproject.toml uv.lock README.md /app/
ADD src/ /app/src/

# Sync the project into a new environment, using the frozen lockfile
WORKDIR /app
RUN uv sync --frozen --no-dev

EXPOSE 8000

FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

# Update the package os dependencies
RUN apt-get update && apt-get install -y

WORKDIR /app

# Copy the project files into the image
COPY --from=builder /app /app

EXPOSE 8000

0 comments on commit 561b279

Please sign in to comment.