Skip to content

Commit a08993e

Browse files
Migrate from docker/build-push-action to stacker-build-push-action
Signed-off-by: Petu Eusebiu <[email protected]>
1 parent 475d97b commit a08993e

File tree

4 files changed

+154
-40
lines changed

4 files changed

+154
-40
lines changed

.github/workflows/ci-cd.yml

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686

8787
push-image:
8888
if: github.event_name == 'release' && github.event.action== 'published'
89-
name: Push Docker image to GitHub Packages
89+
name: Push OCI images to GitHub Packages
9090
runs-on: ubuntu-latest
9191
strategy:
9292
matrix:
@@ -95,72 +95,77 @@ jobs:
9595
steps:
9696
- name: Check out the repo
9797
uses: actions/checkout@v2
98-
- name: Log in to GitHub Docker Registry
99-
uses: docker/login-action@v1
100-
with:
101-
registry: ghcr.io
102-
username: ${{ github.actor }}
103-
password: ${{ secrets.GITHUB_TOKEN }}
104-
- name: Build zot container image
105-
uses: docker/build-push-action@v2
98+
- name: Build and push zot container image
99+
uses: project-stacker/stacker-build-push-action@main
106100
with:
101+
file: 'stacker.yaml'
107102
build-args: |
108103
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
109104
OS=${{ matrix.os }}
110105
ARCH=${{ matrix.arch }}
111-
push: true
112-
file: Dockerfile
113-
tags: |
114-
ghcr.io/${{ github.repository }}-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}
115-
ghcr.io/${{ github.repository }}-${{ matrix.os }}-${{ matrix.arch }}:latest
116-
- name: Build zot-minimal container image
117-
uses: docker/build-push-action@v2
106+
REPO_NAME=zot-${{ matrix.os }}-${{ matrix.arch }}
107+
url: docker://ghcr.io/${{ github.repository_owner }}
108+
tags: ${{ github.event.release.tag_name }} latest
109+
username: ${{ github.actor }}
110+
password: ${{ secrets.GITHUB_TOKEN }}
111+
- name: Build and push zot-minimal container image
112+
uses: project-stacker/stacker-build-push-action@main
118113
with:
114+
file: 'stacker.yaml'
119115
build-args: |
120116
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
121117
OS=${{ matrix.os }}
122118
ARCH=${{ matrix.arch }}
123-
push: true
124-
file: Dockerfile-minimal
125-
tags: |
126-
ghcr.io/${{ github.repository }}-minimal-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}
127-
ghcr.io/${{ github.repository }}-minimal-${{ matrix.os }}-${{ matrix.arch }}:latest
128-
- name: Build zot-exporter container image
129-
uses: docker/build-push-action@v2
119+
EXT=-minimal
120+
REPO_NAME=zot-minimal-${{ matrix.os }}-${{ matrix.arch }}
121+
url: docker://ghcr.io/${{ github.repository_owner }}
122+
tags: ${{ github.event.release.tag_name }} latest
123+
username: ${{ github.actor }}
124+
password: ${{ secrets.GITHUB_TOKEN }}
125+
- name: Build and push zot-exporter container image
126+
uses: project-stacker/stacker-build-push-action@main
130127
with:
128+
file: 'stacker-zxp.yaml'
131129
build-args: |
132130
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
133131
OS=${{ matrix.os }}
134132
ARCH=${{ matrix.arch }}
135-
push: true
136-
file: Dockerfile-zxp
137-
tags: |
138-
ghcr.io/${{ github.repository }}-zxp-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}
139-
ghcr.io/${{ github.repository }}-zxp-${{ matrix.os }}-${{ matrix.arch }}:latest
140-
- name: Build zb container image
141-
uses: docker/build-push-action@v2
133+
REPO_NAME=zxp-${{ matrix.os }}-${{ matrix.arch }}
134+
url: docker://ghcr.io/${{ github.repository_owner }}
135+
tags: ${{ github.event.release.tag_name }} latest
136+
username: ${{ github.actor }}
137+
password: ${{ secrets.GITHUB_TOKEN }}
138+
- name: Build and push zb container image
139+
uses: project-stacker/stacker-build-push-action@main
142140
with:
141+
file: 'stacker-zb.yaml'
143142
build-args: |
144143
COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }}
145144
OS=${{ matrix.os }}
146145
ARCH=${{ matrix.arch }}
147-
push: true
148-
file: Dockerfile-zb
149-
tags: |
150-
ghcr.io/${{ github.repository }}-zb-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}
151-
ghcr.io/${{ github.repository }}-zb-${{ matrix.os }}-${{ matrix.arch }}:latest
146+
REPO_NAME=zb-${{ matrix.os }}-${{ matrix.arch }}
147+
url: docker://ghcr.io/${{ github.repository_owner }}
148+
tags: ${{ github.event.release.tag_name }} latest
149+
username: ${{ github.actor }}
150+
password: ${{ secrets.GITHUB_TOKEN }}
152151
- name: Run Trivy vulnerability scanner
153152
uses: aquasecurity/trivy-action@master
154153
with:
155154
image-ref: 'ghcr.io/${{ github.repository }}-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}'
156155
format: 'sarif'
157156
output: 'trivy-results.sarif'
157+
env:
158+
TRIVY_USERNAME: ${{ github.actor }}
159+
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
158160
- name: Run Trivy vulnerability scanner (minimal)
159161
uses: aquasecurity/trivy-action@master
160162
with:
161163
image-ref: 'ghcr.io/${{ github.repository }}-minimal-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }}'
162164
format: 'sarif'
163165
output: 'trivy-results.sarif'
166+
env:
167+
TRIVY_USERNAME: ${{ github.actor }}
168+
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
164169
- name: Upload Trivy scan results to GitHub Security tab
165170
uses: github/codeql-action/upload-sarif@v1
166171
with:

stacker-zb.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
build:
2+
from:
3+
type: docker
4+
url: docker://ghcr.io/project-zot/golang:1.17
5+
binds:
6+
- . -> /zotcopy
7+
run: |
8+
export GO111MODULE=on
9+
export GOPATH='/go'
10+
export HOME='/root'
11+
export PATH='/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
12+
mkdir -p /go/src/github.com/project-zot
13+
cd /go/src/github.com/project-zot
14+
git clone /zotcopy zot
15+
cd /go/src/github.com/project-zot/zot
16+
make COMMIT=${{COMMIT}} OS=${{OS}} ARCH=${{ARCH}} clean bench
17+
build_only: true
18+
19+
"${{REPO_NAME:zb}}":
20+
from:
21+
type: docker
22+
url: docker://centos:latest
23+
import:
24+
- stacker://build/go/src/github.com/project-zot/zot/bin/zb-${{OS}}-${{ARCH}}
25+
run: |
26+
cp /stacker/zb-${{OS}}-${{ARCH}} /usr/bin/zb
27+
entrypoint:
28+
- /usr/bin/zb

stacker-zxp.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
build:
2+
from:
3+
type: docker
4+
url: docker://ghcr.io/project-zot/golang:1.17
5+
binds:
6+
- . -> /zotcopy
7+
run: |
8+
export GO111MODULE=on
9+
export GOPATH='/go'
10+
export HOME='/root'
11+
export PATH='/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
12+
mkdir -p /go/src/github.com/project-zot
13+
cd /go/src/github.com/project-zot
14+
git clone /zotcopy zot
15+
cd /go/src/github.com/project-zot/zot
16+
make COMMIT=${{COMMIT}} OS=${{OS}} ARCH=${{ARCH}} clean exporter-minimal
17+
18+
cat > config.json << EOF
19+
{
20+
"Server":{
21+
"protocol":"http",
22+
"host": "127.0.0.1",
23+
"port": "5000"
24+
},
25+
"Exporter":{
26+
"port":"5001",
27+
"log":{
28+
"level":"debug"
29+
}
30+
}
31+
}
32+
EOF
33+
34+
cat config.json
35+
build_only: true
36+
37+
"${{REPO_NAME:zxp}}":
38+
from:
39+
type: docker
40+
url: docker://centos:latest
41+
import:
42+
- stacker://build/go/src/github.com/project-zot/zot/bin/zxp-${{OS}}-${{ARCH}}
43+
- stacker://build/go/src/github.com/project-zot/zot/config.json
44+
run: |
45+
cp /stacker/zxp-${{OS}}-${{ARCH}} /usr/bin/zxp
46+
mkdir -p /etc/zxp
47+
cp /stacker/config.json /etc/zxp/config.json
48+
entrypoint:
49+
- /usr/bin/zxp
50+
cmd:
51+
- config
52+
- /etc/zxp/config.json

stacker.yaml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build:
33
type: docker
44
url: docker://ghcr.io/project-zot/golang:1.17
55
binds:
6-
- ${{PWD}} -> /zotcopy
6+
- . -> /zotcopy
77
run: |
88
export GO111MODULE=on
99
export GOPATH='/go'
@@ -14,14 +14,43 @@ build:
1414
cd /go/src/github.com/project-zot
1515
git clone /zotcopy zot
1616
cd /go/src/github.com/project-zot/zot
17-
make binary
17+
make COMMIT=${{COMMIT}} OS=${{OS}} ARCH=${{ARCH}} binary${{EXT:}}
18+
cat > config.json << EOF
19+
{
20+
"storage":{
21+
"rootDirectory":"/var/lib/registry"
22+
},
23+
"http":{
24+
"address":"0.0.0.0",
25+
"port":"5000"
26+
},
27+
"log":{
28+
"level":"debug"
29+
}
30+
}
31+
EOF
32+
33+
cat config.json
1834
build_only: true
1935

20-
zot:
36+
"${{REPO_NAME:zot}}":
2137
from:
2238
type: docker
2339
url: docker://centos:latest
2440
import:
25-
- ${{PWD}}/bin/zot
41+
- stacker://build/go/src/github.com/project-zot/zot/bin/zot-${{OS}}-${{ARCH}}${{EXT:}}
42+
- stacker://build/go/src/github.com/project-zot/zot/config.json
43+
- stacker://build/etc/ssl/certs/ca-certificates.crt
2644
run: |
27-
cp /stacker/zot /usr/bin/zot
45+
cp /stacker/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
46+
cp /stacker/zot-${{OS}}-${{ARCH}}${{EXT:}} /usr/bin/zot
47+
mkdir -p /etc/zot
48+
cp /stacker/config.json /etc/zot/config.json
49+
entrypoint:
50+
- /usr/bin/zot
51+
volumes:
52+
- /var/lib/registry
53+
cmd:
54+
- serve
55+
- /etc/zot/config.json
56+

0 commit comments

Comments
 (0)