Skip to content

Commit

Permalink
Merge pull request #1376 from robbrockbank/pass-env-to-containerized-…
Browse files Browse the repository at this point in the history
…build

Add envs to containerized binary build
  • Loading branch information
robbrockbank authored Dec 2, 2016
2 parents db17336 + d2570be commit 0bb9a0a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,19 @@ semaphore: clean
bash -c 'rm -rf /home/runner/{.npm,.phpbrew,.phpunit,.kerl,.kiex,.lein,.nvm,.npm,.phpbrew,.rbenv}'

# Actually run the tests (refreshing the images as required), we only run a
# small subset of the tests for testing SSL support.
CALICOCTL_NODE_VERSION=$$BRANCH_NAME $(MAKE) calico/ctl calico/node st
CALICOCTL_NODE_VERSION=$$BRANCH_NAME ST_TO_RUN=tests/st/policy $(MAKE) st-ssl
# small subset of the tests for testing SSL support. These tests are run
# using "latest" tagged images.
$(MAKE) calico/ctl calico/node st
ST_TO_RUN=tests/st/policy $(MAKE) st-ssl

# Assumes that a few environment variables exist - BRANCH_NAME PULL_REQUEST_NUMBER
# If this isn't a PR, then push :BRANCHNAME tagged images to Dockerhub and quay for both calico/node and calico/ctl
# If this isn't a PR, then push :BRANCHNAME tagged and :CALICOCONTAINERS_VERSION
# tagged images to Dockerhub and quay for both calico/node and calico/ctl. This
# requires a rebuild of calico/ctl in both cases.
set -e; \
if [ -z $$PULL_REQUEST_NUMBER ]; then \
rm dist/calicoctl ;\
CALICOCTL_NODE_VERSION=$$BRANCHNAME $(MAKE) calico/ctl ;\
docker tag $(NODE_CONTAINER_NAME) quay.io/$(NODE_CONTAINER_NAME):$$BRANCH_NAME && \
docker push quay.io/$(NODE_CONTAINER_NAME):$$BRANCH_NAME; \
docker tag $(NODE_CONTAINER_NAME) $(NODE_CONTAINER_NAME):$$BRANCH_NAME && \
Expand Down Expand Up @@ -390,18 +395,22 @@ dist/calicoctl-darwin-amd64: $(CALICOCTL_FILES) vendor
dist/calicoctl-windows-amd64: $(CALICOCTL_FILES) vendor
$(MAKE) OS=windows ARCH=amd64 binary-containerized


## Run the build in a container. Useful for CI
binary-containerized: $(CALICOCTL_FILES) vendor
mkdir -p dist
docker run --rm \
-e OS=$(OS) -e ARCH=$(ARCH) \
-e CALICOCONTAINERS_VERSION=$(CALICOCONTAINERS_VERSION) -e CALICOCTL_NODE_VERSION=$(CALICOCTL_NODE_VERSION) \
-e CALICOCTL_BUILD_DATE=$(CALICOCTL_BUILD_DATE) -e CALICOCTL_GIT_REVISION=$(CALICOCTL_GIT_REVISION) \
-v ${PWD}:/go/src/github.com/projectcalico/calico-containers:ro \
-v ${PWD}/dist:/go/src/github.com/projectcalico/calico-containers/dist \
golang:1.7 bash -c '\
cd /go/src/github.com/projectcalico/calico-containers && \
make OS=$(OS) ARCH=$(ARCH) binary && \
chown -R $(shell id -u):$(shell id -u) dist'
make OS=$(OS) ARCH=$(ARCH) \
CALICOCONTAINERS_VERSION=$(CALICOCONTAINERS_VERSION) CALICOCTL_NODE_VERSION=$(CALICOCTL_NODE_VERSION) \
CALICOCTL_BUILD_DATE=$(CALICOCTL_BUILD_DATE) CALICOCTL_GIT_REVISION=$(CALICOCTL_GIT_REVISION) \
binary && \
chown -R $(shell id -u):$(shell id -u) dist'

## Etcd is used by the tests
.PHONY: run-etcd
Expand Down Expand Up @@ -472,7 +481,6 @@ endif
docker tag $(NODE_CONTAINER_NAME) quay.io/$(NODE_CONTAINER_NAME):latest
docker tag $(CTL_CONTAINER_NAME) quay.io/$(CTL_CONTAINER_NAME):latest


# Check that images were created recently and that the IDs of the versioned and latest images match
@docker images --format "{{.CreatedAt}}\tID:{{.ID}}\t{{.Repository}}:{{.Tag}}" $(NODE_CONTAINER_NAME)
@docker images --format "{{.CreatedAt}}\tID:{{.ID}}\t{{.Repository}}:{{.Tag}}" $(NODE_CONTAINER_NAME):$(VERSION)
Expand Down

0 comments on commit 0bb9a0a

Please sign in to comment.