Skip to content

Commit

Permalink
feat: multi-stages build πŸŽ‰ (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
wliao008 authored Oct 17, 2022
1 parent 1ac2406 commit 990da83
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
FROM golang:1.18
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
FROM golang:1.18 as builder
RUN mkdir /build
ADD . /build
WORKDIR /build
RUN CGO_ENABLED=1 go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .

FROM alpine:latest
RUN apk --no-cache add ca-certificates
#RUN apk update && apk add libc6-compat
WORKDIR /app/
RUN mkdir -p ./static/css ./templates
COPY --from=builder /build/main ./
COPY --from=builder /build/static/css/ ./static/css/
COPY --from=builder /build/templates/ ./templates/
CMD ["./main"]

0 comments on commit 990da83

Please sign in to comment.