commit
f6f2b4e986
|
@ -0,0 +1,88 @@
|
|||
# These environment variables must be set in CircleCI UI
|
||||
#
|
||||
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
|
||||
# DOCKER_USER - login info for docker hub
|
||||
# DOCKER_PASS
|
||||
#
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: docker:18.02.0-ce
|
||||
working_directory: /dockerflow
|
||||
steps:
|
||||
# workaround circleci's fallback git's "object not found" error w/ tag
|
||||
# builds
|
||||
- run:
|
||||
name: Install Docker build dependencies
|
||||
command: apk add --no-cache openssh-client git
|
||||
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
|
||||
- run:
|
||||
name: Build Docker image
|
||||
command: docker build -t app:build .
|
||||
|
||||
# save the built docker container into CircleCI's cache. This is
|
||||
# required since Workflows do not have the same remote docker instance.
|
||||
- run:
|
||||
name: docker save app:build
|
||||
command: mkdir -p /cache; docker save -o /cache/docker.tar "app:build"
|
||||
- save_cache:
|
||||
key: v1-{{ .Branch }}-{{ .Environment.CIRCLE_TAG }}-{{ epoch }}
|
||||
paths:
|
||||
- /cache/docker.tar
|
||||
|
||||
deploy:
|
||||
docker:
|
||||
- image: docker:18.02.0-ce
|
||||
steps:
|
||||
- setup_remote_docker
|
||||
- restore_cache:
|
||||
key: v1-{{.Branch}}
|
||||
- run:
|
||||
name: Restore Docker image cache
|
||||
command: docker load -i /cache/docker.tar
|
||||
|
||||
- run:
|
||||
name: Deploy to Dockerhub
|
||||
command: |
|
||||
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
||||
DOCKER_TAG="latest"
|
||||
fi
|
||||
|
||||
if echo "${CIRCLE_BRANCH}" | grep '^feature\..*' > /dev/null; then
|
||||
DOCKER_TAG="${CIRCLE_BRANCH}"
|
||||
fi
|
||||
|
||||
if [ -n "${CIRCLE_TAG}" ]; then
|
||||
DOCKER_TAG="$CIRCLE_TAG"
|
||||
fi
|
||||
|
||||
if [ -n "${DOCKER_TAG}" ]; then
|
||||
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
|
||||
echo ${DOCKERHUB_REPO}:${DOCKER_TAG}
|
||||
docker tag app:build ${DOCKERHUB_REPO}:${DOCKER_TAG}
|
||||
docker images
|
||||
docker push "${DOCKERHUB_REPO}:${DOCKER_TAG}"
|
||||
else
|
||||
echo "Not pushing to dockerhub for tag=${CIRCLE_TAG} branch=${CIRCLE_BRANCH}"
|
||||
fi
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build-deploy:
|
||||
jobs:
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
|
||||
- deploy:
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
|
12
circle.yml
12
circle.yml
|
@ -1,12 +0,0 @@
|
|||
# circle ci file
|
||||
machine:
|
||||
post:
|
||||
- pyenv global 2.7.13 3.5
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
- pip install -r test-requirements.txt
|
||||
|
||||
test:
|
||||
override:
|
||||
- nosetests -v pywebpush
|
Loading…
Reference in New Issue