diff --git a/Dockerfile b/Dockerfile index 2579505..e402224 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,29 @@ -FROM golang:alpine AS builder +FROM golang:1.19.2-alpine3.16 as builder LABEL stage=gobuilder RUN apk add --no-cache git build-base linux-headers -WORKDIR /build +WORKDIR /app + +# download and cache go mod +COPY ./go.* ./ -ADD go.mod . -ADD go.sum . RUN go env -w GO111MODULE=on && go mod download + COPY . . -RUN go build -ldflags="-s -w" -o /app/main cmd/main.go +RUN make build -FROM scratch -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai -ENV TZ Asia/Shanghai +FROM alpine:3.16 -WORKDIR /app -COPY --from=builder /app/main /app/main -CMD ["./main"] +WORKDIR root + +COPY --from=builder /app/build/bin/firewalld /usr/bin/firewalld + + +VOLUME ["/root"] + +ENTRYPOINT ["firewalld"]