Skip to content

Commit c0b8cfa

Browse files
committed
Docker Image - CircleCI Automatic Push
1 parent 8ef6a5b commit c0b8cfa

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

.circleci/config.yml

+29-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,32 @@ jobs:
3131

3232
- run:
3333
name: Run Tests
34-
command: carton exec prove -lv
34+
command: carton exec prove -lv
35+
36+
- setup_remote_docker
37+
38+
- run:
39+
name: Install Docker client
40+
when: on_success
41+
command: |
42+
if [ "${CIRCLE_BRANCH}" == "circle-ci" ]; then
43+
set -x
44+
VER="17.03.0-ce"
45+
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
46+
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
47+
mv /tmp/docker/* /usr/bin
48+
else
49+
echo "Not master branch so no docker required"
50+
fi
51+
52+
- run:
53+
name: Build and Push Docker Image
54+
when: on_success
55+
shell: /bin/bash
56+
command: |
57+
if [ "${CIRCLE_BRANCH}" == "circle-ci" ]; then
58+
docker login -u ${DOCKER_LOGIN} -p ${DOCKER_PASSWORD}
59+
make update push_ci
60+
else
61+
echo "Not master branch, So no push to DockerHub"
62+
fi

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ RELEASE_VERSION ?= latest
1010
LOCAL_IMAGE := $(NAME):$(RELEASE_VERSION)
1111
REMOTE_IMAGE := $(NAMESPACE)/$(LOCAL_IMAGE)
1212

13+
CIRLE_SHA1 ?= ''
14+
REMOTE_IMAGE_CI := $(NAMESPACE)/$(NAME):$(CIRCLE_SHA1)
15+
1316
# Environment General Settings
1417
ENVIRONMENT ?= devel
1518
SECRETS_URL ?= 'https://www.dropbox.com/s/p9x87ffn19rdr0c/secrets.mk.gpg'
@@ -92,6 +95,10 @@ tag: ## Tag IMAGE_NAME
9295
push: tag ## Push to the docker registry
9396
docker push $(REMOTE_IMAGE)
9497

98+
push_ci:
99+
docker tag $(LOCAL_IMAGE) $(REMOTE_IMAGE_CI)
100+
docker push $(REMOTE_IMAGE_CI)
101+
95102
pull: ## Pull the docker from the Registry
96103
docker pull $(REMOTE_IMAGE)
97104

0 commit comments

Comments
 (0)