Skip to content

Commit

Permalink
Finally fix the binary builds for a couple os/arch combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Robinson committed Sep 4, 2018
1 parent 0a78e74 commit c3e9723
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 113 deletions.
79 changes: 18 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,72 +167,29 @@ deploy:
binary: CUSTOMTAG = -${GOOS}-${GOARCH}
binary:
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 -v /tmp/go_pkg_cache:/go/pkg brimstone/golang \
-o app storj.io/storj/cmd/${COMPONENT} \
| tar -x ./app -O > 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

# To update this section, modify and run the following:
# grep -Eo '^[a-z]*_[a-z]*_[a-z0-9]*' Makefile | tr '\n' ' '
.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

COMPONENTLIST := uplink satellite storagenode
OSARCHLIST := linux_amd64 windows_amd64 darwin_amd64 windows_386
.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: $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O))

.PHONY: binaries-upload
binaries-upload:
Expand Down
22 changes: 5 additions & 17 deletions cmd/satellite/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 \
Expand Down
22 changes: 5 additions & 17 deletions cmd/storagenode/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
22 changes: 5 additions & 17 deletions cmd/uplink/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion scripts/fix-mock-overlay
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3e9723

Please sign in to comment.