Skip to content

Commit aba05ed

Browse files
authored
test setcap (#15)
Signed-off-by: wfan <wfan@yahoo-corp.jp>
1 parent 747b118 commit aba05ed

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/docker-build-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
echo ${{ toJSON(steps.sysdig.outputs.violation_report) }} | \
138138
jq -r .
139139
echo ${{ toJSON(steps.sysdig.outputs.violation_report) }} | \
140-
jq -r .cis_docker_benchmark_violation_report[].violations[] | \
140+
jq -r '.cis_docker_benchmark_violation_report[] | select(true) | .violations[]' | \
141141
wc -l | \
142142
xargs -I% test 0 -eq %
143143

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM golang:1.20-alpine AS base
22

33
RUN set -eux \
44
&& apk --no-cache add ca-certificates \
5-
&& apk --no-cache add --virtual build-dependencies cmake g++ make unzip curl git
5+
&& apk --no-cache add --virtual build-dependencies cmake g++ make unzip curl git libcap
66

77
WORKDIR ${GOPATH}/src/github.com/AthenZ/garm
88

@@ -32,6 +32,9 @@ RUN BUILD_TIME=$(date -u +%Y%m%d-%H%M%S) \
3232
go build -ldflags "-s -w -linkmode 'external' -extldflags '-static -fPIC -m64 -pthread -std=c++11 -lstdc++' -X 'main.Version=${APP_VERSION} at ${BUILD_TIME} by ${GO_VERSION}'" -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \
3333
&& mv "${APP_NAME}" "/usr/bin/${APP_NAME}"
3434

35+
# allow well-known port binding
36+
RUN setcap 'cap_net_bind_service=+ep' "/usr/bin/${APP_NAME}"
37+
3538
RUN apk del build-dependencies --purge \
3639
&& rm -rf "${GOPATH}"
3740

@@ -50,7 +53,7 @@ COPY --from=builder /etc/passwd /etc/passwd
5053
COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME}
5154
# Copy user
5255
COPY --from=builder /etc/passwd /etc/passwd
53-
# USER ${APP_NAME}
56+
USER ${APP_NAME}
5457

5558
HEALTHCHECK NONE
5659
ENTRYPOINT ["/go/bin/garm"]

0 commit comments

Comments
 (0)