Skip to content

Commit

Permalink
Improved Dockerfile for cross-platform build.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemarkom committed Nov 15, 2021
1 parent 8f32a29 commit c803c22
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM golang:alpine AS pitemp-builder
FROM --platform=${BUILDPLATFORM} golang:alpine AS builder

# Builder image
WORKDIR /pitemp
COPY . .
RUN GOOS="linux" GOARCH=$(uname -m | sed -e "s/aarch64/arm64/" -e "s/x86_64/amd64/" -e "s/armv7l/arm/") go build
ARG TARGETOS
ARG TARGETARCH
RUN apk --no-cache add ca-certificates
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build

# Final image
FROM alpine:latest
RUN apk --no-cache add ca-certificates
#RUN apt-get update && apt-get install --yes ca-certificates
COPY --from=pitemp-builder /pitemp/pitemp /usr/local/bin/pitemp
ENTRYPOINT ["/usr/local/bin/pitemp"]
FROM alpine:latest AS pitemp
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /pitemp/pitemp /
WORKDIR /
ENV PATH "/"
ENTRYPOINT ["pitemp"]
CMD ["--help"]

0 comments on commit c803c22

Please sign in to comment.