Skip to content

Commit 88a8bdb

Browse files
Merge pull request #1 from max-rocket-internet/non_root
switching to use non-root user and read-only file system
2 parents f95958a + 917475b commit 88a8bdb

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ WORKDIR /go/src/github.com/deliveryhero/k8s-event-logger
33
COPY main.go .
44
RUN go get -d -v ./...
55
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
6-
6+
RUN adduser --disabled-login --no-create-home --disabled-password --system --uid 101 non-root
77
FROM alpine:3.9.3
88
RUN apk --no-cache add ca-certificates
9-
WORKDIR /root/
9+
WORKDIR /
1010
COPY --from=0 /go/src/github.com/deliveryhero/k8s-event-logger/main k8s-event-logger
11-
CMD ["/root/k8s-event-logger"]
11+
USER 101
12+
ENV USER non-root
13+
CMD ["/k8s-event-logger"]

chart/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ spec:
2828
- name: app
2929
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
3030
imagePullPolicy: {{ .Values.image.pullPolicy }}
31+
securityContext:
32+
readOnlyRootFilesystem: true
33+
runAsNonRoot: true
3134
env:
3235
{{- range $key, $value := .Values.env }}
3336
- name: {{ $key }}

chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
image:
22
repository: tools4k8s/k8s-event-logger
3-
tag: "1.2"
3+
tag: "1.3"
44
pullPolicy: IfNotPresent
55

66
resources:

0 commit comments

Comments
 (0)