Skip to content

Commit

Permalink
Merge pull request #153 from tomdee/version-in-container
Browse files Browse the repository at this point in the history
Pass through version into build container
  • Loading branch information
caseydavenport authored Aug 19, 2016
2 parents 3617758 + c852fa6 commit cea86de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:/opt/cni/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
RUN mkdir -p /opt/cni/bin
ARG CALICO_CNI_VERSION
ENV CALICO_CNI_VERSION ${CALICO_CNI_VERSION}

# Add source files.
ADD glide.yaml glide.lock Makefile /go/src/github.com/projectcalico/calico-cni/
Expand All @@ -29,7 +31,7 @@ RUN set -ex \
make \
&& go get -u github.com/Masterminds/glide \
&& cd /go/src/github.com/projectcalico/calico-cni \
&& make binary \
&& make binary CALICO_CNI_VERSION=$CALICO_CNI_VERSION \
&& mv dist/calico* /opt/cni/bin \
&& rm -rf /go /root/.glide \
&& apk del .build-deps
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LOCAL_IP_ENV?=$(shell ip route get 8.8.8.8 | head -1 | cut -d' ' -f8)
K8S_VERSION=1.3.1
CALICO_NODE_VERSION=0.20.0

CALICO_CNI_VERSION?=$(shell git describe --tags --dirty)

# Ensure that the dist directory is always created
MAKE_SURE_DIST_EXIST := $(shell mkdir -p dist)

Expand Down Expand Up @@ -33,12 +35,12 @@ vendor:
# Build the Calico network plugin
dist/calico: $(SRCFILES) vendor
CGO_ENABLED=0 go build -v -o dist/calico \
-ldflags "-X main.VERSION=$(shell git describe --tags --dirty)" calico.go;
-ldflags "-X main.VERSION=$(CALICO_CNI_VERSION)" calico.go;

# Build the Calico ipam plugin
dist/calico-ipam: $(SRCFILES) vendor
CGO_ENABLED=0 go build -v -o dist/calico-ipam \
-ldflags "-X main.VERSION=$(shell git describe --tags --dirty)" ipam/calico-ipam.go;
-ldflags "-X main.VERSION=$(CALICO_CNI_VERSION)" ipam/calico-ipam.go;

.PHONY: test
# Run the unit tests.
Expand All @@ -56,7 +58,7 @@ $(BUILD_CONTAINER_MARKER): Dockerfile.build
touch $@

$(DEPLOY_CONTAINER_MARKER): Dockerfile
docker build -f Dockerfile -t $(DEPLOY_CONTAINER_NAME) .
docker build -f Dockerfile --build-arg CALICO_CNI_VERSION=$(CALICO_CNI_VERSION) -t $(DEPLOY_CONTAINER_NAME) .
touch $@

# Run the tests in a container. Useful for CI
Expand Down

0 comments on commit cea86de

Please sign in to comment.