Fix the binaries and Docker Images (#306)

* Finally fix the binary builds for a couple os/arch combinations

* Make the file executable before adding it to the zip

* This cache hack wasn't suppose to make it into the PR

* Guard against calling the binary target by itself

* Order matters on OS X

* Vendored my image

* No 386 builds until storage is fixed.
This commit is contained in:
Matt Robinson 2018-09-05 16:40:47 -04:00 committed by Philip Hutchins
parent a4d1070d68
commit 2c315db84b
5 changed files with 37 additions and 112 deletions

View File

@ -166,73 +166,34 @@ deploy:
.PHONY: binary
binary: CUSTOMTAG = -${GOOS}-${GOARCH}
binary:
@if [ -z "${COMPONENT}" ]; then echo "Try one of the following targets instead:" \
&& for b in binaries ${BINARIES}; do echo "- $$b"; done && exit 1; fi
mkdir -p release/${TAG}
CUSTOMTAG=$(CUSTOMTAG) $(MAKE) $(COMPONENT)-image
cid=$$(docker create storjlabs/$(COMPONENT):${TAG}${CUSTOMTAG}) \
&& docker cp $$cid:/app/$(COMPONENT) release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT} \
&& docker rm $$cid
docker rmi storjlabs/$(COMPONENT):${TAG}${CUSTOMTAG}
tar -c . | docker run --rm -i -e TAR=1 -e GO111MODULE=on \
-e GOOS=${GOOS} -e GOARCH=${GOARCH} -e CGO_ENABLED=1 \
-w /go/src/storj.io/storj storjlabs/golang \
-o app storj.io/storj/cmd/${COMPONENT} \
| tar -O -x ./app > release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT}
chmod 755 release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT}
rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}.zip
cd release/${TAG}; zip ${COMPONENT}_${GOOS}_${GOARCH}.zip ${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT}
rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT}
# To update this section, modify and run the following:
# for c in satellite storagenode uplink; do \
# for oa in "darwin amd64" "linux 386" \
# "linux amd64" "windows 386" "windows amd64"; do \
# echo "$c $oa"; done; done | while read -r c o a; do; \
# printf ".PHONY: ${c}_${o}_${a}\n${c}_${o}_${a}:\n\tGOOS=${o} GOARCH=${a} COMPONENT=${c} \$(MAKE) binary\n"; \
# done
.PHONY: satellite_darwin_amd64
satellite_darwin_amd64:
GOOS=darwin GOARCH=amd64 COMPONENT=satellite $(MAKE) binary
.PHONY: satellite_linux_386
satellite_linux_386:
GOOS=linux GOARCH=386 COMPONENT=satellite $(MAKE) binary
.PHONY: satellite_linux_amd64
satellite_linux_amd64:
GOOS=linux GOARCH=amd64 COMPONENT=satellite $(MAKE) binary
.PHONY: satellite_windows_386
satellite_windows_386:
GOOS=windows GOARCH=386 COMPONENT=satellite $(MAKE) binary
.PHONY: satellite_windows_amd64
satellite_windows_amd64:
GOOS=windows GOARCH=amd64 COMPONENT=satellite $(MAKE) binary
.PHONY: storagenode_darwin_amd64
storagenode_darwin_amd64:
GOOS=darwin GOARCH=amd64 COMPONENT=storagenode $(MAKE) binary
.PHONY: storagenode_linux_386
storagenode_linux_386:
GOOS=linux GOARCH=386 COMPONENT=storagenode $(MAKE) binary
.PHONY: storagenode_linux_amd64
storagenode_linux_amd64:
GOOS=linux GOARCH=amd64 COMPONENT=storagenode $(MAKE) binary
.PHONY: storagenode_windows_386
storagenode_windows_386:
GOOS=windows GOARCH=386 COMPONENT=storagenode $(MAKE) binary
.PHONY: storagenode_windows_amd64
storagenode_windows_amd64:
GOOS=windows GOARCH=amd64 COMPONENT=storagenode $(MAKE) binary
.PHONY: uplink_darwin_amd64
uplink_darwin_amd64:
GOOS=darwin GOARCH=amd64 COMPONENT=uplink $(MAKE) binary
.PHONY: uplink_linux_386
uplink_linux_386:
GOOS=linux GOARCH=386 COMPONENT=uplink $(MAKE) binary
.PHONY: uplink_linux_amd64
uplink_linux_amd64:
GOOS=linux GOARCH=amd64 COMPONENT=uplink $(MAKE) binary
.PHONY: uplink_windows_386
uplink_windows_386:
GOOS=windows GOARCH=386 COMPONENT=uplink $(MAKE) binary
.PHONY: uplink_windows_amd64
uplink_windows_amd64:
GOOS=windows GOARCH=amd64 COMPONENT=uplink $(MAKE) binary
.PHONY: satellite_%
satellite_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=satellite $(MAKE) binary
.PHONY: storagenode_%
storagenode_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=storagenode $(MAKE) binary
.PHONY: uplink_%
uplink_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=uplink $(MAKE) binary
# To update this section, modify and run the following:
# grep -Eo '^[a-z]*_[a-z]*_[a-z0-9]*' Makefile | tr '\n' ' '
COMPONENTLIST := uplink satellite storagenode
OSARCHLIST := linux_amd64 windows_amd64 darwin_amd64
BINARIES := $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O))
.PHONY: binaries
binaries: satellite_darwin_amd64 satellite_linux_386 satellite_linux_amd64 satellite_windows_386 satellite_windows_amd64 storagenode_darwin_amd64 storagenode_linux_386 storagenode_linux_amd64 storagenode_windows_386 storagenode_windows_amd64 uplink_darwin_amd64 uplink_linux_386 uplink_linux_amd64 uplink_windows_386 uplink_windows_amd64
binaries: ${BINARIES}
.PHONY: binaries-upload
binaries-upload:

View File

@ -1,19 +1,7 @@
ARG GO_VERSION=1.11
FROM golang:${GO_VERSION}-alpine AS build-env
ARG GOOS=linux
ARG GOARCH=amd64
ARG LDFLAGS=
RUN apk add -U curl git musl-dev gcc
COPY . /go/src/storj.io/storj
ENV GOOS=${GOOS} \
GOARCH=${GOARCH} \
LDFLAGS=${LDFLAGS} \
GOARM=6 \
CGO_ENABLED=0 \
GO111MODULE=on
RUN cd /go/src/storj.io/storj/cmd/satellite \
&& go build -o satellite -ldflags "-s -w $LDFLAGS"
ARG CGO_ENABLED=1
ARG REPOSITORY=../storj.io/storj
ARG PACKAGE=storj.io/storj/cmd/satellite
FROM brimstone/golang as build-env
# final stage
FROM alpine
@ -24,7 +12,7 @@ ENV REDIS_ADDR=redis:6379 \
HTTP_PORT=:8080 \
BOOTSTRAP_ADDR=bootstrap.storj.io:8080
WORKDIR /app
COPY --from=build-env /go/src/storj.io/storj/cmd/satellite/satellite /app/
COPY --from=build-env /app /app/satellite
COPY cmd/satellite/entrypoint /entrypoint
EXPOSE 8081/udp \
8080 \

View File

@ -1,19 +1,7 @@
ARG GO_VERSION=1.11
FROM golang:${GO_VERSION}-alpine AS build-env
ARG GOOS=linux
ARG GOARCH=amd64
ARG LDFLAGS=
RUN apk add -U curl git musl-dev gcc
COPY . /go/src/storj.io/storj
ENV GOOS=${GOOS} \
GOARCH=${GOARCH} \
LDFLAGS=${LDFLAGS} \
GOARM=6 \
CGO_ENABLED=0 \
GO111MODULE=on
RUN cd /go/src/storj.io/storj/cmd/storagenode \
&& go build -o storagenode -ldflags "-s -w $LDFLAGS"
ARG CGO_ENABLED=1
ARG REPOSITORY=../storj.io/storj
ARG PACKAGE=storj.io/storj/cmd/storagenode
FROM brimstone/golang as build-env
# final stage
FROM alpine
@ -22,6 +10,6 @@ ENV CONF_PATH= \
EXPOSE 7777
WORKDIR /app
COPY --from=build-env /go/src/storj.io/storj/cmd/storagenode/storagenode /app/
COPY --from=build-env /app /app/storagenode
COPY cmd/storagenode/entrypoint /entrypoint
ENTRYPOINT ["/entrypoint"]

View File

@ -1,19 +1,7 @@
ARG GO_VERSION=1.11
FROM golang:${GO_VERSION}-alpine AS build-env
ARG GOOS=linux
ARG GOARCH=amd64
ARG LDFLAGS=
RUN apk add -U curl git musl-dev gcc
COPY . /go/src/storj.io/storj
ENV GOOS=${GOOS} \
GOARCH=${GOARCH} \
LDFLAGS=${LDFLAGS} \
GOARM=6 \
CGO_ENABLED=0 \
GO111MODULE=on
RUN cd /go/src/storj.io/storj/cmd/uplink \
&& go build -o uplink -ldflags "-s -w $LDFLAGS"
ARG CGO_ENABLED=1
ARG REPOSITORY=../storj.io/storj
ARG PACKAGE=storj.io/storj/cmd/uplink
FROM brimstone/golang as build-env
# final stage
FROM alpine
@ -23,6 +11,6 @@ EXPOSE 7777
WORKDIR /app
COPY --from=build-env /go/src/storj.io/storj/cmd/uplink/uplink /app/
COPY --from=build-env /app /app/uplink
COPY cmd/uplink/entrypoint /entrypoint
ENTRYPOINT ["/entrypoint"]

View File

@ -3,7 +3,7 @@ set -euo pipefail
ids="$(
for cid in $(docker ps | awk '/storage-node/{print $1}'); do
for cid in $(docker ps -a | awk '/storagenode/{print $1}'); do
ip="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cid)"
id="$(docker logs $cid 2>&1 | awk '/started/{print $5; exit}')"
echo $id:$ip:7777