From 8cfa06cf4d9bf9397f745c6298f0d6ee41ddd425 Mon Sep 17 00:00:00 2001 From: Niels Zeilemaker Date: Thu, 28 Jan 2021 16:58:58 +0100 Subject: [PATCH 1/3] Create dockerhub_ci.yml --- .github/workflows/dockerhub_ci.yml | 112 +++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/dockerhub_ci.yml diff --git a/.github/workflows/dockerhub_ci.yml b/.github/workflows/dockerhub_ci.yml new file mode 100644 index 0000000..0795bc4 --- /dev/null +++ b/.github/workflows/dockerhub_ci.yml @@ -0,0 +1,112 @@ +name: Dockerhub CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + # Triggers every week on tuesday night + - cron: '0 0 * * 2' + +env: + # Specify which image to build + DOCKER_REPO: godatadriven/pyspark + +jobs: + build: + name: build + runs-on: ubuntu-latest + strategy: + matrix: + # Specify which tags to build + DOCKER_TAG: ["1.3.0-spark,latest", "1.3.0-nospark", "1.2.0-spark", "1.2.0-nospark", "1.1.0-spark", "1.1.0-nospark"] + + timeout-minutes: 30 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Parse args + id: args + run: | + DOCKER_TAG="${{ matrix.DOCKER_TAG }}" + IMAGE_TAG="${DOCKER_TAG%%,*}" + + # Manipulate DOCKER_TAG to create build args + JH_VERSION=${IMAGE_TAG%-*} + SPARK_VERSION=${IMAGE_TAG#*-} + + if [ $SPARK_VERSION = "nospark" ]; then + DOCKER_FILE="./Dockerfile_NoSpark" + else + DOCKER_FILE="./Dockerfile" + fi + + BUILD_ARGS="JH_VERSION=$JH_VERSION" + + # No modification needed beyond this point + BUILD_ARGS="${BUILD_ARGS//'%'/'%25'}" + BUILD_ARGS="${BUILD_ARGS//$'\n'/'%0A'}" + BUILD_ARGS="${BUILD_ARGS//$'\r'/'%0D'}" + + echo "::set-output name=build_args::$BUILD_ARGS" + echo "::set-output name=dockerfile::$DOCKER_FILE" + + - name: Prepare + id: prep + run: | + DOCKER_TAG="${{ matrix.DOCKER_TAG }}" + DOCKER_IMAGE_NAME="$DOCKER_REPO:${DOCKER_TAG%%,*}" + echo ::set-output name=image_name::${DOCKER_IMAGE_NAME} + + TAGS="$DOCKER_REPO:${DOCKER_TAG//,/,$DOCKER_REPO:}" + echo ::set-output name=tags::${TAGS} + + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: ${{ steps.args.outputs.dockerfile }} + push: false + tags: ${{ steps.prep.outputs.tags }} + build-args: | + ${{ steps.args.outputs.build_args }} + labels: | + org.opencontainers.image.source=${{ github.event.repository.clone_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} + + - name: Test image + env: + IMAGE_NAME: ${{ steps.prep.outputs.image_name }} + run: | + if [[ -f "docker-compose.test.yml" ]]; then + docker-compose --file docker-compose.test.yml build + docker-compose --file docker-compose.test.yml run sut + fi + + - name: Login to DockerHub + if: github.ref == 'refs/heads/master' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB }} + + - name: Push image + if: github.ref == 'refs/heads/master' + run: | + docker push $DOCKER_REPO + + - name: Report Status + if: always() && github.ref == 'refs/heads/master' + uses: ravsamhq/notify-slack-action@master + with: + status: ${{ job.status }} + notify_when: 'failure' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GDD_GENERAL_WEBHOOK }} From bae8d1fbe3fb07e5a56c6ee18e6bc1280af4bc3b Mon Sep 17 00:00:00 2001 From: Niels Zeilemaker Date: Thu, 28 Jan 2021 17:18:18 +0100 Subject: [PATCH 2/3] Switch to 1.2.2 --- .github/workflows/dockerhub_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub_ci.yml b/.github/workflows/dockerhub_ci.yml index 0795bc4..cfe0b44 100644 --- a/.github/workflows/dockerhub_ci.yml +++ b/.github/workflows/dockerhub_ci.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: # Specify which tags to build - DOCKER_TAG: ["1.3.0-spark,latest", "1.3.0-nospark", "1.2.0-spark", "1.2.0-nospark", "1.1.0-spark", "1.1.0-nospark"] + DOCKER_TAG: ["1.3.0-spark,latest", "1.3.0-nospark", "1.2.2-spark", "1.2.2-nospark", "1.1.0-spark", "1.1.0-nospark"] timeout-minutes: 30 steps: From 87374bcb6dff20b28fcdd9a351be5699a6b546c9 Mon Sep 17 00:00:00 2001 From: Niels Zeilemaker Date: Thu, 28 Jan 2021 17:23:06 +0100 Subject: [PATCH 3/3] Switch to jupyterhub repo --- .github/workflows/dockerhub_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub_ci.yml b/.github/workflows/dockerhub_ci.yml index cfe0b44..b635ed2 100644 --- a/.github/workflows/dockerhub_ci.yml +++ b/.github/workflows/dockerhub_ci.yml @@ -13,7 +13,7 @@ on: env: # Specify which image to build - DOCKER_REPO: godatadriven/pyspark + DOCKER_REPO: godatadriven/jupyterhub jobs: build: