As I am on Mac 1, I figured I would get an error attempting to "docker run" this image but I don't.
It was built calling make build
, make image
, and then it was pushed to the remote.
Makefile:
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/retry main.go
.PHONY: image
image: build
docker build -t "my-repo/my-image:latest" --target retry .
Dockerfile:
####################################################################################################
# base
####################################################################################################
FROM alpine:3.12.3 as base
RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata
COPY dist/retry /bin/retry
RUN chmod +x /bin/retry
####################################################################################################
# retry
####################################################################################################
FROM scratch as retry
ARG ARCH
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=base /bin/retry /bin/retry
ENTRYPOINT [ "/bin/retry" ]
I am both able to pull and run this locally as well as through our CI, which I believe uses amd64 machines.
Docker for Mac allows you to run images with an architecture different from the one you're on.
If there were multiple architectures available (e.g. if you built and pushed multiple version) you could even specify the architecture you wanted with the --platform
flag on your docker run
command.