Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
build: docker compile
Browse files Browse the repository at this point in the history
  • Loading branch information
override-coder committed Jul 18, 2023
1 parent 96557f8 commit 1ec4149
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 1ec4149

Please sign in to comment.