From 1ca8fec597ab8b611be3d17bea9b5188a7cf61da Mon Sep 17 00:00:00 2001 From: Gerald Manipon Date: Wed, 8 May 2019 09:19:05 -0700 Subject: [PATCH] use circleci workflows for test, docker build, and deploy to dockerhub - renamed "build" job to "test" and created "test" workflow - will run on all pull requests and merges into master - "build" job now builds isce docker container - "deploy" job will deploy docker image to dockerhub at isce/isce2 (https://cloud.docker.com/u/isce/repository/list) - need to configure DOCKER_PASS and DOCKER_USER in "Build Settings" -> "Envrionment Variables" on circleci - created "build-deploy" workflow to run "build" job then "deploy" job on merge of PR to master - created "build-periodically" workflow to run "build-periodically" job then "deploy" job once a week --- .circleci/config.yml | 114 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7732dd4..ff47213 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ -version: 2 +version: 2.1 jobs: - build: + test: docker: - image: hysds/pge-base:latest user: root @@ -79,5 +79,113 @@ jobs: topsApp.py --help --steps stripmapApp.py --help --steps python3 -c "import isce" - + build: + docker: + - image: docker:stable-git + steps: + - checkout + - setup_remote_docker + - run: + name: Install dependencies + command: | + apk add --no-cache \ + python-dev py-pip bash pigz build-base libffi-dev openssl-dev + pip install \ + docker-compose awscli + - run: + name: Build + command: | + mkdir images + echo 'export TAG="$CIRCLE_SHA1"' >> images/env.sh + source images/env.sh + docker build --rm --force-rm -t isce/isce2:$TAG -f docker/Dockerfile . + cd images + docker save isce/isce2:$TAG > isce2.tar + - persist_to_workspace: + root: images + paths: + - "*" + build-periodically: + docker: + - image: docker:stable-git + steps: + - checkout + - setup_remote_docker + - run: + name: Install dependencies + command: | + apk add --no-cache \ + python-dev py-pip bash pigz build-base libffi-dev openssl-dev + pip install \ + docker-compose awscli + - run: + name: Build + command: | + mkdir images + echo 'export TAG=$(date -u +%Y%m%d)' >> images/env.sh + source images/env.sh + docker build --rm --force-rm -t isce/isce2:$TAG -f docker/Dockerfile . + cd images + docker save isce/isce2:$TAG > isce2.tar + - persist_to_workspace: + root: images + paths: + - "*" + deploy: + docker: + - image: alpine:latest + steps: + - run: + name: Install dependencies + command: | + apk add --no-cache \ + curl file + - attach_workspace: + at: images + - run: + name: Deploy + command: | + cd images + source env.sh + docker load -i isce2.tar + docker tag isce/isce2:$TAG isce/isce2:latest + docker login -u $DOCKER_USER -p $DOCKER_PASS + docker push isce/isce2:$TAG + docker push isce/isce2:latest +workflows: + version: 2 + test: + jobs: + - test + build-deploy: + jobs: + - build: + filters: + branches: + only: master + - deploy: + requires: + - build + filters: + branches: + only: master + weekly: + triggers: + - schedule: + cron: "0 7 * * 0" + filters: + branches: + only: + - master + jobs: + - build-periodically: + filters: + branches: + only: master + - deploy: + requires: + - build-periodically + filters: + branches: + only: master