From 391f08d387ecf308663cc42cfe116301212c57a2 Mon Sep 17 00:00:00 2001 From: Javier Evans Date: Mon, 8 Jan 2024 22:14:50 -0800 Subject: [PATCH] move to a registry strategy to share base images due to buildx --- .github/workflows/main.yml | 133 ++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 69 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 06813390..33926ecb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,13 @@ on: jobs: build-oss: runs-on: ubuntu-latest + services: + registry: + image: registry:2 + ports: + - 5000:5000 + # Note that uploading the artifact won't work. We will need to build and push it to a local registry. + # See here https://docs.docker.com/build/ci/github-actions/named-contexts/#using-with-a-container-builder if: github.ref != 'refs/heads/master' steps: @@ -37,22 +44,25 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + # network=host driver-opt needed to push to local registry + driver-opts: network=host - name: Build and export uses: docker/build-push-action@v5 with: file: Dockerfile.oss context: . tags: nginx-s3-gateway , nginx-s3-gateway:oss - outputs: type=docker,dest=/tmp/oss.tar - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: oss - path: /tmp/oss.tar + push: true test-oss: runs-on: ubuntu-latest needs: build-oss + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.ref != 'refs/heads/master' steps: @@ -79,20 +89,21 @@ jobs: with: path: .bin key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }} - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: oss - path: /tmp - name: Load image run: | - docker load --input /tmp/oss.tar + docker pull localhost:5000/nginx-s3-gateway:oss + docker tag nginx-s3-gateway:oss nginx-s3-gateway - name: Run tests - stable njs version run: ./test.sh --type oss build-latest-njs: runs-on: ubuntu-latest needs: test-oss + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.ref != 'refs/heads/master' steps: @@ -101,33 +112,27 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Download the base artifact - uses: actions/download-artifact@v3 with: - name: oss - path: /tmp - - name: Load image - run: | - docker load --input /tmp/oss.tar - echo "Images:" - docker image ls -a - echo "--------" + # network=host driver-opt needed to push to local registry + driver-opts: network=host - name: Build and export uses: docker/build-push-action@v5 with: file: Dockerfile.latest-njs context: . - tags: nginx-s3-gateway , nginx-s3-gateway:latest-njs-oss - outputs: type=docker,dest=/tmp/latest-njs.tar - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: latest-njs - path: /tmp/latest-njs.tar + tags: nginx-s3-gateway:latest-njs-oss + push: true + build-contexts: | + nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss test-latest-njs: runs-on: ubuntu-latest needs: build-latest-njs + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.ref != 'refs/heads/master' steps: @@ -154,21 +159,21 @@ jobs: with: path: .bin key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }} - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: latest-njs - path: /tmp - name: Load image run: | - docker load --input /tmp/latest-njs.tar + docker pull localhost:5000/nginx-s3-gateway:latest-njs-oss + docker tag nginx-s3-gateway:latest-njs-oss nginx-s3-gateway - name: Run tests - latest njs version - run: ./test.sh --type oss - + run: ./test.sh --latest-njs --type oss build-oss-unprivileged: runs-on: ubuntu-latest needs: test-oss + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.ref != 'refs/heads/master' steps: @@ -177,42 +182,36 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Download the base artifact - uses: actions/download-artifact@v3 with: - name: oss - path: /tmp - - name: Load image - run: | - docker load --input /tmp/oss.tar - echo "Images:" - docker image ls -a - echo "--------" + # network=host driver-opt needed to push to local registry + driver-opts: network=host - name: Build and export uses: docker/build-push-action@v5 with: file: Dockerfile.unprivileged context: . - tags: nginx-s3-gateway , nginx-s3-gateway:unprivileged - outputs: type=docker,dest=/tmp/unprivileged.tar - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: unprivileged - path: /tmp/unprivileged.tar + tags: nginx-s3-gateway:unprivileged + push: true + build-contexts: | + nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss - - name: Run tests - latest njs version - run: ./test.sh --latest-njs --type oss - - name: Run tests - stable njs version - run: ./test.sh --type oss - - name: Run tests - stable njs version - unprivileged process - run: ./test.sh --unprivileged --type oss - - name: Run tests - latest njs version - unprivileged process - run: ./test.sh --latest-njs --unprivileged --type oss + # - name: Run tests - latest njs version + # run: ./test.sh --latest-njs --type oss + # - name: Run tests - stable njs version + # run: ./test.sh --type oss + # - name: Run tests - stable njs version - unprivileged process + # run: ./test.sh --unprivileged --type oss + # - name: Run tests - latest njs version - unprivileged process + # run: ./test.sh --latest-njs --unprivileged --type oss test-oss-unprivileged: runs-on: ubuntu-latest needs: build-oss-unprivileged + services: + registry: + image: registry:2 + ports: + - 5000:5000 if: github.ref != 'refs/heads/master' steps: @@ -239,16 +238,12 @@ jobs: with: path: .bin key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }} - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: unprivileged - path: /tmp - name: Load image run: | - docker load --input /tmp/unprivileged.tar + docker pull localhost:5000/nginx-s3-gateway:unprivileged + docker tag nginx-s3-gateway:unprivileged nginx-s3-gateway - name: Run tests - stable njs version - unprivileged process - run: ./test.sh --type oss + run: ./test.sh --unprivileged --type oss # build_and_deploy: # runs-on: ubuntu-latest