-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
88 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,88 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
working_directory: ~/fred | ||
docker: | ||
- image: circleci/python:3.7-stretch-browsers-legacy | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install Docker Compose | ||
command: | | ||
set -x | ||
curl -L https://github.com/docker/compose/releases/download/1.25.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose | ||
chmod +x /usr/local/bin/docker-compose | ||
- setup_remote_docker | ||
- run: | ||
name: Start container and verify it is working | ||
command: | | ||
set -x | ||
docker-compose up -d | ||
docker run --network container:backend \ | ||
appropriate/curl --retry 10 --retry-delay 1 --retry-connrefused http://localhost:5001/ping | ||
version: 2.1 | ||
executors: | ||
docker-publisher: | ||
environment: | ||
IMAGE_NAME: harrywang/fred | ||
docker: | ||
- image: circleci/buildpack-deps:stretch | ||
jobs: | ||
build: | ||
executor: docker-publisher | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- run: | ||
name: Build Docker image | ||
command: | | ||
docker build -t $IMAGE_NAME:latest . | ||
- run: | ||
name: Archive Docker image | ||
command: docker save -o image.tar $IMAGE_NAME | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- ./image.tar | ||
publish-latest: | ||
executor: docker-publisher | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- setup_remote_docker | ||
- run: | ||
name: Load archived Docker image | ||
command: docker load -i /tmp/workspace/image.tar | ||
- run: | ||
name: Publish Docker Image to Docker Hub | ||
command: | | ||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
IMAGE_TAG="0.0.${CIRCLE_BUILD_NUM}" | ||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG | ||
docker push $IMAGE_NAME:latest | ||
docker push $IMAGE_NAME:$IMAGE_TAG | ||
publish-tag: | ||
executor: docker-publisher | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- setup_remote_docker | ||
- run: | ||
name: Load archived Docker image | ||
command: docker load -i /tmp/workspace/image.tar | ||
- run: | ||
name: Publish Docker Image to Docker Hub | ||
command: | | ||
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
IMAGE_TAG=${CIRCLE_TAG/v/''} | ||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG | ||
docker push $IMAGE_NAME:latest | ||
docker push $IMAGE_NAME:$IMAGE_TAG | ||
workflows: | ||
version: 2 | ||
build-master: | ||
jobs: | ||
- build: | ||
filters: | ||
branches: | ||
only: master | ||
- publish-latest: | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: master | ||
build-tags: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
branches: | ||
ignore: /.*/ | ||
- publish-tag: | ||
requires: | ||
- build | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
branches: | ||
ignore: /.*/ |