Skip to content

Commit a626316

Browse files
committed
Add uid and gid options to cache mounts in Dockerfile
This ensures proper user and group ownership for cache directories when mounting during build steps. It improves compatibility with non-root users and prevents potential permission issues in CI/CD pipelines or local development environments.
1 parent 6f28ad9 commit a626316

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ COPY --chown=nonroot:nonroot Makefile .
4747
# Dev image, contains all files and dependencies
4848
FROM base_builder AS dev
4949
COPY --chown=nonroot:nonroot . .
50-
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked \
50+
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked,uid=$UID,gid=$GID \
5151
make dev-dependencies
5252

5353
# Note that opentelemetry doesn't play well together with uvicorn reloader
@@ -56,22 +56,22 @@ CMD ["uvicorn", "http_app:create_app", "--host", "0.0.0.0", "--port", "8000", "-
5656

5757
# Installs requirements to run production dramatiq application
5858
FROM base_builder AS dramatiq_builder
59-
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked \
59+
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked,uid=$UID,gid=$GID \
6060
uv sync --no-dev --no-install-project --frozen --no-editable
6161

6262
# Installs requirements to run production http application
6363
FROM base_builder AS http_builder
64-
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked \
64+
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked,uid=$UID,gid=$GID \
6565
uv sync --no-dev --group http --no-install-project --frozen --no-editable
6666

6767
# Installs requirements to run production socketio application
6868
FROM base_builder AS socketio_builder
69-
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked \
69+
RUN --mount=type=cache,id=uv,target=/home/nonroot/.cache/uv,sharing=locked,uid=$UID,gid=$GID \
7070
uv sync --no-dev --group socketio --no-install-project --frozen --no-editable
7171

7272
# Installs requirements to run production migrations application
7373
FROM base_builder AS migrations_builder
74-
RUN --mount=type=cache,target=/home/nonroot/.cache/uv,sharing=locked \
74+
RUN --mount=type=cache,target=/home/nonroot/.cache/uv,sharing=locked,uid=$UID,gid=$GID \
7575
uv sync --no-dev --group migrations --no-install-project --frozen --no-editable
7676

7777
# Create the base app with the common python packages

0 commit comments

Comments
 (0)