Skip to content

Commit

Permalink
Publish to docker hub in CI job
Browse files Browse the repository at this point in the history
  • Loading branch information
nfisher committed May 6, 2020
1 parent 4b727d0 commit c72ca8c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
SHELL := /bin/bash -eu
CMDS := $(wildcard cmd/*)
IMGS := $(subst cmd,envcheck,${CMDS})
IMGS := ${DOCKER_REPO}/envcheck-pinger ${DOCKER_REPO}/envcheck-daemon
SRC := $(wildcard cmd/**/*.go) $(wildcard *.go)
GIT_SHA := $(shell git rev-parse --short HEAD)

.PHONY: all
all: vet lint coverage envcheckctl

.PHONY: publish
publish: $(IMGS) all
publish: all $(IMGS)

.PHONY: test
test: cover.out
Expand Down Expand Up @@ -60,10 +60,9 @@ clean:
rm -f *.out
go clean -i ./...

# TODO: Optimise so it only executes on code changes.
# build a docker container per command
.PHONY: envcheck/%
envcheck/%:
docker build . -t ${DOCKER_REPO}/$@:latest -t ${DOCKER_REPO}/$@:${GIT_SHA} --build-arg CMD_PATH=./cmd/$(subst envcheck/,,$@) --build-arg GIT_SHA=${GIT_SHA}
docker push ${DOCKER_REPO}/$@:${GIT_SHA}
docker push ${DOCKER_REPO}/$@:latest
# build a docker container per service
.PHONY: ${DOCKER_REPO}/
${DOCKER_REPO}/%:
docker build . -t $@:latest -t $@:${GIT_SHA} --build-arg CMD_PATH=./cmd/$(subst ${DOCKER_REPO}/envcheck-,,$@) --build-arg GIT_SHA=${GIT_SHA}
docker push $@:${GIT_SHA}
docker push $@:latest
2 changes: 1 addition & 1 deletion base/daemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
hostNetwork: true
containers:
- name: envchecker
image: 192.168.253.99:5001/envcheck/daemon:latest
image: instana/envcheck-daemon:latest
imagePullPolicy: Always
env:
- name: NAME
Expand Down
2 changes: 1 addition & 1 deletion base/pinger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: pinger
image: 192.168.253.99:5001/envcheck/pinger:latest
image: instana/envcheck-pinger:latest
imagePullPolicy: Always
env:
- name: NAME
Expand Down
8 changes: 7 additions & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
version: 0.2
env:
parameter-store:
DOCKER_USER: "hub.docker.com.user"
DOCKER_PASSWORD: "hub.docker.com.password"

phases:
install:
runtime-versions:
golang: 1.14
docker: 19
commands:
- docker login --username $DOCKER_USER --password $DOCKER_PASSWORD
build:
commands:
- make
- make publish

0 comments on commit c72ca8c

Please sign in to comment.