Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ COPY . /app
RUN yarn build

# production environment
FROM nginx:stable-alpine
FROM nginxinc/nginx-unprivileged:stable-alpine

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Pin the production base image to an immutable reference.

Line 12 uses the mutable stable-alpine tag. A rebuild can silently pull different Nginx or Alpine contents. Use a tested version with a digest, such as nginxinc/nginx-unprivileged:<tested-version>-alpine@sha256:<verified-digest>.

As per path instructions, Dockerfiles must flag unpinned base images.

Suggested change and verification
-FROM nginxinc/nginx-unprivileged:stable-alpine
+FROM nginxinc/nginx-unprivileged:<tested-version>-alpine@sha256:<verified-digest>
#!/usr/bin/env bash
set -euo pipefail

tag_info="$(curl -fsSL \
  'https://hub.docker.com/v2/repositories/nginxinc/nginx-unprivileged/tags/stable-alpine')"
digest="$(jq -r '.digest // empty' <<<"$tag_info")"

test -n "$digest"
case "$digest" in
  sha256:*) ;;
  *) exit 1 ;;
esac

printf '%s\n' "$digest"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 12, Replace the mutable stable-alpine reference in the
Dockerfile’s FROM directive with the tested Nginx unprivileged Alpine version
and its verified sha256 digest, preserving the nginxinc/nginx-unprivileged image
while making the base immutable.

COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d

EXPOSE 80
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
5 changes: 4 additions & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repo }}/{{ .Chart.Name }}:{{ .Chart.Version }}"
imagePullPolicy: IfNotPresent
securityContext:
runAsNonRoot: true
runAsUser: 101
ports:
- name: http
containerPort: 80
containerPort: 8080
protocol: TCP
{{- if .Values.probes.enabled }}
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
type: ClusterIP
ports:
- port: {{ .Values.service.port | default 80 }}
targetPort: 80
targetPort: 8080
protocol: TCP
name: http
selector:
Expand Down
2 changes: 1 addition & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80;
listen 8080;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
Expand Down
Loading