diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..67f26621 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!boots-*-* diff --git a/.gitignore b/.gitignore index 621a19a4..eaeccd7f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .idea*/** /bin/ boots +boots-*-* diff --git a/Dockerfile b/Dockerfile index da1dcc3d..9f4d6c30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ FROM alpine:3.11 + +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + ENTRYPOINT ["/usr/bin/boots"] EXPOSE 67 69 80 + RUN apk add --update --upgrade --no-cache ca-certificates socat -COPY . /usr/myapp -RUN cp /usr/myapp/boots-linux-$(uname -m) /usr/bin/boots -RUN rm -fr /usr/myapp +COPY boots-${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT} /usr/bin/boots diff --git a/Makefile b/Makefile index 7d8d6a49..2ff5d8ea 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,23 @@ binary := boots .PHONY: all ${binary} crosscompile dc gen run test all: ${binary} +CGO_ENABLED := 0 +export CGO_ENABLED + GitRev := $(shell git rev-parse --short HEAD) -crosscompile: ${binary} - CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -v -o ./boots-linux-x86_64 -ldflags="-X main.GitRev=${GitRev}" - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./boots-linux-amd64 -ldflags="-X main.GitRev=${GitRev}" - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -v -o ./boots-linux-aarch64 -ldflags="-X main.GitRev=${GitRev}" - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -v -o ./boots-linux-armv7l -ldflags="-X main.GitRev=${GitRev}" - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -v -o ./boots-linux-arm64 -ldflags="-X main.GitRev=${GitRev}" +crosscompile: boots-linux-386 boots-linux-amd64 boots-linux-arm64 boots-linux-armv6 boots-linux-armv7 +boots-linux-386: FLAGS=GOARCH=386 +boots-linux-amd64: FLAGS=GOARCH=amd64 +boots-linux-arm64: FLAGS=GOARCH=arm64 +boots-linux-armv6: FLAGS=GOARCH=arm GOARM=6 +boots-linux-armv7: FLAGS=GOARCH=arm GOARM=7 +boots-linux-386 boots-linux-amd64 boots-linux-arm64 boots-linux-armv6 boots-linux-armv7: ${binary} + ${FLAGS} GOOS=linux go build -v -ldflags="-X main.GitRev=${GitRev}" -o $@ # this is quick and its really only for rebuilding when dev'ing, I wish go would # output deps in make syntax like gcc does... oh well this is good enough ${binary}: $(shell git ls-files | grep -v -e vendor -e '_test.go' | grep '.go$$' ) ipxe/bindata.go - CGO_ENABLED=0 go build -v -ldflags="-X main.GitRev=${GitRev}" + go build -v -ldflags="-X main.GitRev=${GitRev}" ifeq ($(origin GOBIN), undefined) GOBIN := ${PWD}/bin