Skip to content

Commit

Permalink
Make compile via Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Normore committed Jun 18, 2019
1 parent 1b073fe commit 26b7a76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmd/do-csi-plugin/do-csi-plugin
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LDFLAGS ?= -X github.com/digitalocean/csi-digitalocean/driver.version=${VERSION}
PKG ?= github.com/digitalocean/csi-digitalocean/cmd/do-csi-plugin

VERSION ?= $(shell cat VERSION)
DOCKER_REPO ?= digitalocean/do-csi-plugin

all: test

Expand All @@ -33,7 +34,7 @@ bump-version:
.PHONY: compile
compile:
@echo "==> Building the project"
@env CGO_ENABLED=0 GOOS=${OS} GOARCH=amd64 go build -o cmd/do-csi-plugin/${NAME} -ldflags "$(LDFLAGS)" ${PKG}
@docker run --rm -it -e GOOS=${OS} -e GOARCH=amd64 -v ${PWD}/:/app -w /app golang:1.12-alpine sh -c 'apk add git && go build -o cmd/do-csi-plugin/${NAME} -ldflags "$(LDFLAGS)" ${PKG}'


.PHONY: test
Expand All @@ -51,16 +52,16 @@ test-integration:
.PHONY: build
build:
@echo "==> Building the docker image"
@docker build -t digitalocean/do-csi-plugin:$(VERSION) cmd/do-csi-plugin -f cmd/do-csi-plugin/Dockerfile
@docker build -t $(DOCKER_REPO):$(VERSION) cmd/do-csi-plugin -f cmd/do-csi-plugin/Dockerfile

.PHONY: push
push:
ifeq ($(shell [[ $(BRANCH) != "master" && $(VERSION) != "dev" ]] && echo true ),true)
@echo "ERROR: Publishing image with a SEMVER version '$(VERSION)' is only allowed from master"
else
@echo "==> Publishing digitalocean/do-csi-plugin:$(VERSION)"
@docker push digitalocean/do-csi-plugin:$(VERSION)
@echo "==> Your image is now available at digitalocean/do-csi-plugin:$(VERSION)"
@echo "==> Publishing $(DOCKER_REPO):$(VERSION)"
@docker push $(DOCKER_REPO):$(VERSION)
@echo "==> Your image is now available at $(DOCKER_REPO):$(VERSION)"
endif

.PHONY: clean
Expand Down

0 comments on commit 26b7a76

Please sign in to comment.