Skip to content

Commit

Permalink
Merge pull request #12 from jvidalallende/multistage_dockerfile
Browse files Browse the repository at this point in the history
docker: use multi-stage build
  • Loading branch information
ppnaik1890 committed Nov 27, 2023
2 parents d80a72c + e041cac commit d1c5be6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
FROM golang:1.20.10-alpine
# Builder phase, includes golang toolchain
FROM golang:1.20.11-alpine3.18 as builder
COPY . /src
WORKDIR /src
RUN go build -o mq2prom ./cmd

# Runtime phase, contains bare alpine plus the built binary and the config file
# IMPORTANT: keep the alpine version on the builder and the runtime base images aligned
FROM alpine:3.18
RUN mkdir /mq2prom
COPY . /mq2prom
WORKDIR /mq2prom
RUN go build -o mq2prom ./cmd
CMD ./mq2prom
COPY --from=builder /src/mq2prom /src/config.yaml .
CMD ["./mq2prom"]

0 comments on commit d1c5be6

Please sign in to comment.