Skip to content

Commit 9944209

Browse files
committed
attempt a different build strategy to share base image
1 parent 391f08d commit 9944209

File tree

1 file changed

+58
-154
lines changed

1 file changed

+58
-154
lines changed

.github/workflows/main.yml

Lines changed: 58 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727

2828

2929
jobs:
30-
build-oss:
30+
build:
3131
runs-on: ubuntu-latest
3232
services:
3333
registry:
@@ -36,7 +36,11 @@ jobs:
3636
- 5000:5000
3737
# Note that uploading the artifact won't work. We will need to build and push it to a local registry.
3838
# See here https://docs.docker.com/build/ci/github-actions/named-contexts/#using-with-a-container-builder
39-
39+
# This person has my problem: https://stackoverflow.com/questions/75831482/how-to-use-a-local-docker-registry2-from-one-job-as-a-container-for-another-job
40+
# The issue is that the docker container that is the registery does not persist between jobs.
41+
# So I"d need to do something dumb like use the artifact upload and download to get to to the next
42+
# step then do it there.
43+
# Time to cut my losses and do it mostly in one run.
4044
if: github.ref != 'refs/heads/master'
4145
steps:
4246
- uses: actions/checkout@v4
@@ -47,175 +51,60 @@ jobs:
4751
with:
4852
# network=host driver-opt needed to push to local registry
4953
driver-opts: network=host
50-
- name: Build and export
54+
- name: Build and export oss image
5155
uses: docker/build-push-action@v5
5256
with:
5357
file: Dockerfile.oss
5458
context: .
55-
tags: nginx-s3-gateway , nginx-s3-gateway:oss
59+
tags: localhost:5000/nginx-s3-gateway , localhost:5000/nginx-s3-gateway:oss
5660
push: true
57-
58-
test-oss:
59-
runs-on: ubuntu-latest
60-
needs: build-oss
61-
services:
62-
registry:
63-
image: registry:2
64-
ports:
65-
- 5000:5000
66-
67-
if: github.ref != 'refs/heads/master'
68-
steps:
69-
- uses: actions/checkout@v4
70-
- name: Install dependencies
71-
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
72-
- name: Restore cached binaries
73-
id: cache-binaries-restore
74-
uses: actions/cache/restore@v3
75-
with:
76-
path: .bin
77-
key: ${{ runner.os }}-binaries
78-
- name: Install MinIO Client
61+
- name: save image for upload
7962
run: |
80-
mkdir .bin || exit 0
81-
cd .bin
82-
curl --insecure --retry 6 --fail --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
83-
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
84-
mv mc.RELEASE.2023-06-19T19-31-19Z mc
85-
chmod +x mc
86-
- name: Save cached binaries
87-
id: cache-binaries-save
88-
uses: actions/cache/save@v3
63+
docker save localhost:5000/nginx-s3-gateway > oss.tar
64+
- name: Upload artifact - oss
65+
uses: actions/upload-artifact@v3
8966
with:
90-
path: .bin
91-
key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }}
92-
- name: Load image
93-
run: |
94-
docker pull localhost:5000/nginx-s3-gateway:oss
95-
docker tag nginx-s3-gateway:oss nginx-s3-gateway
96-
- name: Run tests - stable njs version
97-
run: ./test.sh --type oss
98-
99-
build-latest-njs:
100-
runs-on: ubuntu-latest
101-
needs: test-oss
102-
services:
103-
registry:
104-
image: registry:2
105-
ports:
106-
- 5000:5000
67+
name: oss
68+
path: /tmp/oss.tar
10769

108-
if: github.ref != 'refs/heads/master'
109-
steps:
110-
- uses: actions/checkout@v4
111-
- name: Set up QEMU
112-
uses: docker/setup-qemu-action@v3
113-
- name: Set up Docker Buildx
114-
uses: docker/setup-buildx-action@v3
115-
with:
116-
# network=host driver-opt needed to push to local registry
117-
driver-opts: network=host
118-
- name: Build and export
70+
- name: Build and export latest-njs image
11971
uses: docker/build-push-action@v5
12072
with:
12173
file: Dockerfile.latest-njs
12274
context: .
123-
tags: nginx-s3-gateway:latest-njs-oss
124-
push: true
75+
tags: localhost:5000/nginx-s3-gateway:latest-njs-oss
76+
push: false
77+
outputs: type=docker,dest=/tmp/latest-njs.tar
12578
build-contexts: |
12679
nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss
127-
128-
test-latest-njs:
129-
runs-on: ubuntu-latest
130-
needs: build-latest-njs
131-
services:
132-
registry:
133-
image: registry:2
134-
ports:
135-
- 5000:5000
136-
137-
if: github.ref != 'refs/heads/master'
138-
steps:
139-
- uses: actions/checkout@v4
140-
- name: Install dependencies
141-
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
142-
- name: Restore cached binaries
143-
id: cache-binaries-restore
144-
uses: actions/cache/restore@v3
145-
with:
146-
path: .bin
147-
key: ${{ runner.os }}-binaries
148-
- name: Install MinIO Client
149-
run: |
150-
mkdir .bin || exit 0
151-
cd .bin
152-
curl --insecure --retry 6 --fail --location --output mc.RELEASE.2023-06-19T19-31-19Z "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z"
153-
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
154-
mv mc.RELEASE.2023-06-19T19-31-19Z mc
155-
chmod +x mc
156-
- name: Save cached binaries
157-
id: cache-binaries-save
158-
uses: actions/cache/save@v3
80+
- name: Upload artifact - latest-njs
81+
uses: actions/upload-artifact@v3
15982
with:
160-
path: .bin
161-
key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }}
162-
- name: Load image
163-
run: |
164-
docker pull localhost:5000/nginx-s3-gateway:latest-njs-oss
165-
docker tag nginx-s3-gateway:latest-njs-oss nginx-s3-gateway
166-
- name: Run tests - latest njs version
167-
run: ./test.sh --latest-njs --type oss
83+
name: latest-njs
84+
path: /tmp/latest-njs.tar
16885

169-
build-oss-unprivileged:
170-
runs-on: ubuntu-latest
171-
needs: test-oss
172-
services:
173-
registry:
174-
image: registry:2
175-
ports:
176-
- 5000:5000
177-
178-
if: github.ref != 'refs/heads/master'
179-
steps:
180-
- uses: actions/checkout@v4
181-
- name: Set up QEMU
182-
uses: docker/setup-qemu-action@v3
183-
- name: Set up Docker Buildx
184-
uses: docker/setup-buildx-action@v3
185-
with:
186-
# network=host driver-opt needed to push to local registry
187-
driver-opts: network=host
188-
- name: Build and export
86+
- name: Build and export - unprivileged
18987
uses: docker/build-push-action@v5
19088
with:
19189
file: Dockerfile.unprivileged
19290
context: .
193-
tags: nginx-s3-gateway:unprivileged
194-
push: true
91+
tags: localhost:5000/nginx-s3-gateway:unprivileged
92+
push: false
93+
outputs: type=docker,dest=/tmp/unprivileged.tar
19594
build-contexts: |
19695
nginx-s3-gateway=docker-image://localhost:5000/nginx-s3-gateway:oss
197-
198-
# - name: Run tests - latest njs version
199-
# run: ./test.sh --latest-njs --type oss
200-
# - name: Run tests - stable njs version
201-
# run: ./test.sh --type oss
202-
# - name: Run tests - stable njs version - unprivileged process
203-
# run: ./test.sh --unprivileged --type oss
204-
# - name: Run tests - latest njs version - unprivileged process
205-
# run: ./test.sh --latest-njs --unprivileged --type oss
206-
207-
test-oss-unprivileged:
96+
- name: Upload artifact - unprivileged
97+
uses: actions/upload-artifact@v3
98+
with:
99+
name: unprivileged
100+
path: /tmp/unprivileged.tar
101+
test:
208102
runs-on: ubuntu-latest
209-
needs: build-oss-unprivileged
210-
services:
211-
registry:
212-
image: registry:2
213-
ports:
214-
- 5000:5000
215-
216103
if: github.ref != 'refs/heads/master'
217104
steps:
218105
- uses: actions/checkout@v4
106+
## Start tests. Keep things here because we can't keep the registry between jobs
107+
## TODO: Try saving the artifact after all are built? What happens to the other archs?
219108
- name: Install dependencies
220109
run: sudo apt-get update -qq && sudo apt-get install -y curl wait-for-it
221110
- name: Restore cached binaries
@@ -232,18 +121,33 @@ jobs:
232121
curl --insecure --retry 6 --fail --silent --location "https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2023-06-19T19-31-19Z.sha256sum" | sha256sum --check -
233122
mv mc.RELEASE.2023-06-19T19-31-19Z mc
234123
chmod +x mc
235-
- name: Save cached binaries
236-
id: cache-binaries-save
237-
uses: actions/cache/save@v3
124+
125+
## OSS Test. No retagging needed
126+
- name: Download artifact
127+
uses: actions/download-artifact@v3
238128
with:
239-
path: .bin
240-
key: ${{ steps.cache-binaries-restore.outputs.cache-primary-key }}
129+
name: oss
130+
path: /tmp
241131
- name: Load image
242132
run: |
243-
docker pull localhost:5000/nginx-s3-gateway:unprivileged
244-
docker tag nginx-s3-gateway:unprivileged nginx-s3-gateway
245-
- name: Run tests - stable njs version - unprivileged process
246-
run: ./test.sh --unprivileged --type oss
133+
docker load --input /tmp/oss.tar
134+
- name: Run tests - stable njs version
135+
run: ./test.sh --type oss
136+
137+
# ## Latest NJS test. Requires that we retag the latest njs one as the primary for now
138+
# - name: Load image latest-oss
139+
# run: |
140+
# docker pull localhost:5000/nginx-s3-gateway:latest-njs-oss
141+
# docker tag nginx-s3-gateway:latest-njs-oss nginx-s3-gateway
142+
# - name: Run tests - latest njs version
143+
# run: ./test.sh --latest-njs --type oss
144+
145+
# - name: Load image - unprivilegedp
146+
# run: |
147+
# docker pull localhost:5000/nginx-s3-gateway:unprivileged
148+
# docker tag nginx-s3-gateway:unprivileged nginx-s3-gateway
149+
# - name: Run tests - stable njs version - unprivileged process
150+
# run: ./test.sh --unprivileged --type oss
247151

248152
# build_and_deploy:
249153
# runs-on: ubuntu-latest

0 commit comments

Comments
 (0)