Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM golang:1.10

RUN apt-get update && apt-get install -y zip
RUN apt-get update \
&& apt-get install -y zip \
&& apt-get install -y sudo libltdl-dev

RUN go get -d golang.org/x/sys/unix
RUN go get -d github.com/Microsoft/hcsshim
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ CNM_PLUGIN_ROOTFS = azure-vnet-plugin-rootfs
AZURE_NPM_IMAGE = containernetworking/azure-npm

VERSION ?= $(shell git describe --tags --always --dirty)
AZURE_NPM_VERSION = VERSION
AZURE_NPM_VERSION = $(VERSION)

ENSURE_OUTPUT_DIR_EXISTS := $(shell mkdir -p $(OUTPUT_DIR))

Expand All @@ -120,6 +120,8 @@ else
all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns
endif

all-images: azure-npm-image

# Clean all build artifacts.
.PHONY: clean
clean:
Expand All @@ -146,17 +148,20 @@ $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT): $(NPMFILES)
go build -v -o $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT) -ldflags "-X main.version=$(VERSION) -s -w" $(NPM_DIR)/*.go

# Build all binaries in a container.
.PHONY: all-binaries-containerized
all-binaries-containerized:
.PHONY: all-containerized
all-containerized:
pwd && ls -l
docker build -f Dockerfile.build -t $(BUILD_CONTAINER_IMAGE):$(VERSION) .
docker run --name $(BUILD_CONTAINER_NAME) \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
$(BUILD_CONTAINER_IMAGE):$(VERSION) \
bash -c '\
pwd && ls -l && \
export GOOS=$(GOOS) && \
export GOARCH=$(GOARCH) && \
make all-binaries && \
make all-images && \
chown -R $(BUILD_USER):$(BUILD_USER) $(BUILD_DIR) \
'
docker cp $(BUILD_CONTAINER_NAME):$(BUILD_CONTAINER_REPO_PATH)/$(BUILD_DIR) $(OUTPUT_DIR)
Expand Down
13 changes: 12 additions & 1 deletion build/build-all-containerized.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
#!/usr/bin/env bash
GOOS=$1 GOARCH=$2 make all-binaries-containerized

BUILD_CONTAINER_NAME=acn-builder
GOOS=$1
GOARCH=$2

if [ ! "$(docker ps -q -f name=$BUILD_CONTAINER_NAME)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=$BUILD_CONTAINER_NAME)" ]; then
docker rm -f $BUILD_CONTAINER_NAME
fi
fi

make all-containerized