Skip to content
Closed
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
2 changes: 1 addition & 1 deletion ci/Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

FROM ${BASE_IMAGE}

COPY --from=deb /opt/tyk-gateway /opt/tyk-gateway
COPY --chown=65532:65532 --from=deb /opt/tyk-gateway /opt/tyk-gateway

Check warning on line 17 in ci/Dockerfile.distroless

View check run for this annotation

probelabs / Visor: architecture

architecture Issue

The UID and GID `65532` are hard-coded in the `COPY` instruction. This couples the image to a specific user ID, which can cause permission issues in environments that enforce different UIDs for security reasons (e.g., OpenShift). This reduces the image's portability and flexibility.
Raw output
To make the image more adaptable, define the UID and GID using build arguments (`ARG`) and reference them in the `--chown` flag. This allows the user/group to be configured at build time. For example:
```dockerfile
ARG TYK_UID=65532
ARG TYK_GID=65532

COPY --chown=${TYK_UID}:${TYK_GID} --from=deb /opt/tyk-gateway /opt/tyk-gateway
```

Check warning on line 17 in ci/Dockerfile.distroless

View check run for this annotation

probelabs / Visor: quality

style Issue

The UID/GID `65532` is hardcoded. This same value is also used in the `USER` instruction. Using a hardcoded 'magic number' in multiple places makes the Dockerfile harder to maintain. If the non-root user ID needs to change in the future (e.g., due to a base image update), it will have to be found and replaced in all locations.
Raw output
To improve maintainability and readability, define an `ARG` for the user/group ID at the top of the final stage and use this variable in both the `COPY` and `USER` instructions. For example:

```dockerfile
FROM ${BASE_IMAGE}

ARG TYK_UID=65532

COPY --chown=${TYK_UID}:${TYK_UID} --from=deb /opt/tyk-gateway /opt/tyk-gateway

...

USER ${TYK_UID}:${TYK_UID}
```

ARG PORTS
EXPOSE $PORTS
Expand Down
Loading