Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some good security practices #40

Closed
wants to merge 3 commits into from
Closed
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
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM golang:1.20-alpine AS builder

WORKDIR /go/src/webhook-app
COPY . .
RUN --mount=type=cache,target=$HOME/go/pkg/mod go mod download
Expand All @@ -9,9 +8,19 @@ ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /webhook-app -ldflags '-w -extldflags "-static"' .

FROM alpine:3
ENV USER=godaddyWebhook
ENV UID=2050
ENV GID=2050

RUN addgroup --system --gid ${GID} ${USER}

RUN adduser --system --disabled-password --home /home/${USER} \
--uid ${UID} --ingroup ${USER} ${USER}

RUN apk add --no-cache git ca-certificates

COPY --from=builder /webhook-app /usr/local/bin/webhook
RUN chown -R ${UID}:${GID} /usr/local/bin/webhook
USER ${UID}

ENTRYPOINT ["webhook"]
10 changes: 10 additions & 0 deletions deploy/charts/godaddy-webhook/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsGroup: 2050
runAsNonRoot: true
runAsUser: 2050
seccompProfile:
type: RuntimeDefault
args:
- --tls-cert-file=/tls/tls.crt
- --tls-private-key-file=/tls/tls.key
Expand Down
Loading