Skip to content

Commit

Permalink
move to a registry strategy to share base images due to buildx
Browse files Browse the repository at this point in the history
  • Loading branch information
4141done committed Jan 9, 2024
1 parent 0d84f4f commit 391f08d
Showing 1 changed file with 64 additions and 69 deletions.
133 changes: 64 additions & 69 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 391f08d

Please sign in to comment.