Skip to content

Commit a053362

Browse files
committed
feat: add non-root user to Docker images for PSA restricted compliance
Create a hatchet system user (UID 1000) in all three Dockerfiles so Kubernetes deployments can opt into non-root execution via securityContext. Images continue to run as root by default for backward compatibility. To run as non-root, set runAsUser: 1000 in the pod securityContext or pass --user 1000 to docker run. Signed-off-by: Will Corrigan <will-corrigan@users.noreply.github.com>
1 parent db140b7 commit a053362

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

build/package/dashboard.dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ COPY --from=frontend-build /app/dist /usr/share/nginx/html
3333
# Make entrypoint script executable
3434
RUN chmod +x ./entrypoint.sh
3535

36+
# Create non-root user for Kubernetes Pod Security Standards compliance.
37+
# Image defaults to root for backward compatibility (nginx requires root for port 80).
38+
# For non-root nginx, consider nginxinc/nginx-unprivileged:alpine in a future major version.
39+
RUN addgroup -S hatchet && adduser -S -G hatchet -H -s /sbin/nologin -u 1000 hatchet
40+
3641
EXPOSE 80
3742

3843
# Run the entrypoint script

build/package/frontend.dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ WORKDIR /app
2929
COPY --from=build /app/dist ./dist
3030
COPY --from=staticfileserver /app/hatchet-staticfileserver ./hatchet-staticfileserver
3131

32+
# Create non-root user for Kubernetes Pod Security Standards compliance.
33+
# Image defaults to root for backward compatibility. To run as non-root,
34+
# set securityContext.runAsUser: 1000 in your Kubernetes pod spec or
35+
# pass --user 1000 to docker run.
36+
RUN addgroup -S hatchet && adduser -S -G hatchet -H -s /sbin/nologin -u 1000 hatchet
37+
3238
EXPOSE 80
3339

3440
CMD ["/app/hatchet-staticfileserver", "-static-asset-dir", "/app/dist"]

build/package/servers.dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ COPY --from=build-go /hatchet/bin/hatchet-${SERVER_TARGET} /hatchet/
8181
COPY /hack/db/atlas-apply.sh ./atlas-apply.sh
8282
RUN chmod +x ./atlas-apply.sh
8383

84+
# Create non-root user for Kubernetes Pod Security Standards compliance.
85+
# Image defaults to root for backward compatibility. To run as non-root,
86+
# set securityContext.runAsUser: 1000 in your Kubernetes pod spec or
87+
# pass --user 1000 to docker run.
88+
RUN addgroup -S hatchet && adduser -S -G hatchet -H -s /sbin/nologin -u 1000 hatchet
89+
8490
EXPOSE 8080
8591

8692
CMD ["/bin/sh", "-c", "/hatchet/hatchet-${SERVER_TARGET}"]

0 commit comments

Comments
 (0)