chore: remove unnecessary setcap from dockerfile

This commit is contained in:
yusing 2025-04-27 17:27:01 +08:00
parent 38e8f8d553
commit 628dc94924
2 changed files with 12 additions and 14 deletions

View file

@ -4,22 +4,20 @@ HEALTHCHECK NONE
# package version does not matter # package version does not matter
# trunk-ignore(hadolint/DL3018) # trunk-ignore(hadolint/DL3018)
RUN apk add --no-cache tzdata make libcap-setcap RUN apk add --no-cache tzdata make
# Stage 2: builder # Stage 2: builder
FROM deps AS builder FROM deps AS builder
WORKDIR /src WORKDIR /src
COPY go.mod go.sum ./
COPY Makefile ./ COPY Makefile ./
COPY cmd ./cmd COPY cmd ./cmd
COPY internal ./internal COPY internal ./internal
COPY pkg ./pkg COPY pkg ./pkg
COPY agent ./agent COPY agent ./agent
# Only copy go.mod and go.sum initially for better caching
COPY go.mod go.sum /src/
ENV GOPATH=/root/go ENV GOPATH=/root/go
RUN go mod download -x RUN go mod download -x
@ -31,9 +29,8 @@ ENV MAKE_ARGS=${MAKE_ARGS}
ENV GOCACHE=/root/.cache/go-build ENV GOCACHE=/root/.cache/go-build
ENV GOPATH=/root/go ENV GOPATH=/root/go
RUN make ${MAKE_ARGS} build link-binary && \ RUN make ${MAKE_ARGS} docker=1 build link-binary && \
mv bin /app/ && \ mv bin /app/
mkdir -p /app/error_pages /app/certs
# Stage 3: Final image # Stage 3: Final image
FROM scratch FROM scratch
@ -45,10 +42,7 @@ LABEL proxy.exclude=1
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# copy binary # copy binary
COPY --from=builder /app /app COPY --from=builder /app/bin /app/bin
# copy example config
COPY config.example.yml /app/config/config.yml
# copy certs # copy certs
COPY --from=builder /etc/ssl/certs /etc/ssl/certs COPY --from=builder /etc/ssl/certs /etc/ssl/certs

View file

@ -53,10 +53,14 @@ export GODEBUG
export GORACE export GORACE
export BUILD_FLAGS export BUILD_FLAGS
ifeq ($(shell id -u), 0) ifeq (${docker}, 0)
SETCAP_CMD = setcap ifeq ($(shell id -u), 0)
SETCAP_CMD = setcap
else
SETCAP_CMD = sudo setcap
endif
else else
SETCAP_CMD = sudo setcap SETCAP_CMD = echo
endif endif
.PHONY: debug .PHONY: debug