Skip to content

Commit

Permalink
Docker Image - CircleCI Automatic Push
Browse files Browse the repository at this point in the history
  • Loading branch information
maneta committed Sep 9, 2017
1 parent 8ef6a5b commit 4116c00
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,32 @@ jobs:

- run:
name: Run Tests
command: carton exec prove -lv
command: carton exec prove -lv

- setup_remote_docker

- run:
name: Install Docker client
when: on_success
command: |
if [ "${CIRCLE_BRANCH}" == "circle-ci" ]; then
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
else
echo "Not master branch so no docker required"
fi
- run:
name: Build and Push Docker Image
when: on_success
shell: /bin/bash
command: |
if [ "${CIRCLE_BRANCH}" == "circle-ci" ]; then
docker login -u ${DOCKER_LOGIN} -p ${DOCKER_PASSWORD}
make push deploy_ci
else
echo "Not master branch, So no push to DockerHub"
fi
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RELEASE_VERSION ?= latest
LOCAL_IMAGE := $(NAME):$(RELEASE_VERSION)
REMOTE_IMAGE := $(NAMESPACE)/$(LOCAL_IMAGE)

CIRLE_SHA1 ?= ''
REMOTE_IMAGE_CI := $(NAMESPACE)/$(NAME):$(CIRCLE_SHA1)

# Environment General Settings
ENVIRONMENT ?= devel
SECRETS_URL ?= 'https://www.dropbox.com/s/p9x87ffn19rdr0c/secrets.mk.gpg'
Expand Down Expand Up @@ -40,6 +43,7 @@ endif

all: test update ## Test, Build and Push Docker Image to the Registry
update: build push ## Build and Push Docker Image to the Registry
deploy_ci: build push_ci

build: ## Build docker image with name LOCAL_IMAGE (NAME:RELEASE_VERSION).
docker build -f $(THISDIR_PATH)/Dockerfile -t $(LOCAL_IMAGE) $(PROJECT_PATH)
Expand Down Expand Up @@ -92,6 +96,10 @@ tag: ## Tag IMAGE_NAME
push: tag ## Push to the docker registry
docker push $(REMOTE_IMAGE)

push_ci:
docker tag $(LOCAL_IMAGE) $(REMOTE_IMAGE_CI)
docker push $(REMOTE_IMAGE_CI)

pull: ## Pull the docker from the Registry
docker pull $(REMOTE_IMAGE)

Expand Down

0 comments on commit 4116c00

Please sign in to comment.