Skip to content

Commit

Permalink
Merge pull request #489 from tomdee/image-tags
Browse files Browse the repository at this point in the history
Makefile: Make the ARCH part of the tag name not the image name and add pthread to busybox
  • Loading branch information
tomdee authored Aug 19, 2016
2 parents 18ddbd5 + 2243d07 commit 3a9ed14
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist/*.tar.gz
dist/flanneld*
dist/iptables-*
dist/libpthread*
dist/*.aci
dist/*.docker
cover.out
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ MAINTAINER Tom Denham <[email protected]>
COPY dist/flanneld-amd64 /opt/bin/flanneld
COPY dist/iptables-amd64 /usr/local/bin/iptables
COPY dist/mk-docker-opts.sh /opt/bin/
COPY dist/libpthread.so.0-amd64 /lib/libpthread.so.0
CMD ["/opt/bin/flanneld"]

3 changes: 2 additions & 1 deletion Dockerfile.arm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ MAINTAINER Tom Denham <[email protected]>
COPY dist/flanneld-arm /opt/bin/flanneld
COPY dist/iptables-arm /usr/local/bin/iptables
COPY dist/mk-docker-opts.sh /opt/bin/
CMD ["/opt/bin/flanneld"]
COPY dist/libpthread.so.0-arm /lib/libpthread.so.0
CMD ["/opt/bin/flanneld"]
1 change: 1 addition & 0 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ MAINTAINER Tom Denham <[email protected]>
COPY dist/flanneld-arm64 /opt/bin/flanneld
COPY dist/iptables-arm64 /usr/local/bin/iptables
COPY dist/mk-docker-opts.sh /opt/bin/
COPY dist/libpthread.so.0-arm64 /lib/libpthread.so.0
CMD ["/opt/bin/flanneld"]

1 change: 1 addition & 0 deletions Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ MAINTAINER Tom Denham <[email protected]>
COPY dist/flanneld-ppc64le /opt/bin/flanneld
COPY dist/iptables-ppc64le /usr/local/bin/iptables
COPY dist/mk-docker-opts.sh /opt/bin/
COPY dist/libpthread.so.0-ppc64le /lib/libpthread.so.0
CMD ["/opt/bin/flanneld"]

38 changes: 23 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ PACKAGES_EXPANDED=$(PACKAGES:%=github.com/coreos/flannel/%)

# Set the (cross) compiler to use for different architectures
ifeq ($(ARCH),amd64)
LIB_DIR=x86_64-linux-gnu
CC=gcc
endif
ifeq ($(ARCH),arm)
LIB_DIR=arm-linux-gnueabi
CC=arm-linux-gnueabi-gcc
endif
ifeq ($(ARCH),arm64)
LIB_DIR=aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc
endif
ifeq ($(ARCH),ppc64le)
LIB_DIR=powerpc64le-linux-gnu
CC=powerpc64le-linux-gnu-gcc
endif
GOARM=6
Expand Down Expand Up @@ -62,25 +66,25 @@ clean:
rm -f dist/*.tar.gz

## Create a docker image on disk for a specific arch and tag
dist/flanneld-$(ARCH)-$(TAG).docker: dist/flanneld-$(ARCH) dist/iptables-$(ARCH)
docker build -f Dockerfile.$(ARCH) -t $(REGISTRY)/flannel-$(ARCH):$(TAG) .
docker save -o dist/flanneld-$(ARCH)-$(TAG).docker $(REGISTRY)/flannel-$(ARCH):$(TAG)
dist/flanneld-$(TAG)-$(ARCH).docker: dist/flanneld-$(ARCH) dist/iptables-$(ARCH) dist/libpthread.so.0-$(ARCH)
docker build -f Dockerfile.$(ARCH) -t $(REGISTRY)/flannel:$(TAG)-$(ARCH) .
docker save -o dist/flanneld-$(TAG)-$(ARCH).docker $(REGISTRY)/flannel:$(TAG)-$(ARCH)

# amd64 gets an image with the suffix too (i.e. it's the default)
ifeq ($(ARCH),amd64)
docker build -f Dockerfile.$(ARCH) -t $(REGISTRY)/flannel:$(TAG) .
endif

## Create an ACI on disk for a specific arch and tag
dist/flanneld-$(ARCH)-$(TAG).aci: dist/flanneld-$(ARCH)-$(TAG).docker
docker2aci dist/flanneld-$(ARCH)-$(TAG).docker
mv quay.io-coreos-flannel-$(ARCH)-$(TAG).aci dist/flanneld-$(ARCH)-$(TAG).aci
dist/flanneld-$(TAG)-$(ARCH).aci: dist/flanneld-$(TAG)-$(ARCH).docker
docker2aci dist/flanneld-$(TAG)-$(ARCH).docker
mv quay.io-coreos-flannel-$(TAG)-$(ARCH).aci dist/flanneld-$(TAG)-$(ARCH).aci
actool patch-manifest --replace --capability=CAP_NET_ADMIN \
--mounts=run-flannel,path=/run/flannel,readOnly=false:etc-ssl-etcd,path=/etc/ssl/etcd,readOnly=true:dev-net,path=/dev/net,readOnly=false \
dist/flanneld-$(ARCH)-$(TAG).aci
dist/flanneld-$(TAG)-$(ARCH).aci

docker-push: dist/flanneld-$(ARCH)-$(TAG).docker
docker push $(REGISTRY)/flannel-$(ARCH):$(TAG)
docker-push: dist/flanneld-$(TAG)-$(ARCH).docker
docker push $(REGISTRY)/flannel:$(TAG)-$(ARCH)

# amd64 gets an image with the suffix too (i.e. it's the default)
ifeq ($(ARCH),amd64)
Expand All @@ -89,8 +93,8 @@ endif

## Build an architecture specific flanneld binary
dist/flanneld-$(ARCH):
# Build for other platforms with ARCH=$ARCH make build
# valid values for $ARCH are [amd64 arm arm64 ppc64le]
# Build for other platforms with ARCH=$$ARCH make build
# valid values for $$ARCH are [amd64 arm arm64 ppc64le]
docker run -e CC=$(CC) -e GOARM=$(GOARM) -e GOARCH=$(ARCH) -it \
-u $(shell id -u):$(shell id -u) \
-v ${PWD}:/go/src/github.com/coreos/flannel:ro \
Expand All @@ -101,6 +105,10 @@ dist/flanneld-$(ARCH):
mv dist/flanneld dist/flanneld-$(ARCH) && \
file dist/flanneld-$(ARCH)'

## Busybox images are missing pthread. Pull it out of the kube-cross image
dist/libpthread.so.0-$(ARCH):
docker run -ti --rm -v `pwd`:/host gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) cp /lib/$(LIB_DIR)/libpthread.so.0 /host/dist/libpthread.so.0-$(ARCH)

## Build an architecture specific iptables binary
dist/iptables-$(ARCH):
docker run -e CC=$(CC) -e GOARM=$(GOARM) -e GOARCH=$(ARCH) -it \
Expand Down Expand Up @@ -132,10 +140,10 @@ dist/flannel-$(TAG)-linux-amd64.tar.gz:

## Make a release after creating a tag
release: dist/flannel-$(TAG)-linux-amd64.tar.gz
ARCH=amd64 make dist/flanneld-amd64-$(TAG).aci
ARCH=arm make dist/flanneld-arm-$(TAG).aci
ARCH=arm64 make dist/flanneld-arm64-$(TAG).aci
ARCH=ppc64le make dist/flanneld-ppc64le-$(TAG).aci
ARCH=amd64 make dist/flanneld-$(TAG)-amd64.aci
ARCH=arm make dist/flanneld-$(TAG)-arm.aci
ARCH=arm64 make dist/flanneld-$(TAG)-arm64.aci
ARCH=ppc64le make dist/flanneld-$(TAG)-ppc64le.aci
@echo "Everything should be built for $(TAG)"
@echo "Add all *.aci, flanneld-* and *.tar.gz files from dist/ to the Github release"
@echo "Use make docker-push-all to push the images to a registry"
Expand Down

0 comments on commit 3a9ed14

Please sign in to comment.