Add support for ARM in Dockerfile (#254)

* Add support for ARM in Dockerfile

Create script dockerbuild.sh to check
if the CPU is amd64,arm or arm64 so GOARCH can be dynamicly defined
instead of hardcoding amd64

* Use case - esac

* Add ARG GOARCH

Add ARG GOARCH so when defined in `docker ----build-arg` it will compile
to this target platform, otherwise use the arch defined by the
build host.

* Use simpler docker build command

- Add GOOS=linux and GOARCH=amd64 in Dockerfile
- Remove dockerbuild.sh

* Use empty ARG values
This commit is contained in:
mrmenndev
2022-09-01 09:40:49 +03:00
committed by GitHub
parent dd823da5ad
commit 621bd1914f

View File

@@ -1,9 +1,11 @@
FROM golang:alpine as builder
ARG GOOS
ARG GOARCH
WORKDIR /build
COPY . .
WORKDIR cmd/routedns
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
RUN GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build
FROM alpine:latest
COPY --from=builder /build/cmd/routedns/routedns .