Skip to content

Commit 57dc8e1

Browse files
authored
Refactoring everything: New workflows, new bakefile (#24)
1 parent fecdae4 commit 57dc8e1

13 files changed

Lines changed: 405 additions & 138 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
33
{
44
"name": "Base Gui",
5-
"build": {
6-
// Sets the run context to one level up instead of the .devcontainer folder.
7-
"context": "..",
8-
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9-
"dockerfile": "../Dockerfile",
10-
"args": {
11-
"OS": "debian:bookworm"
12-
}
13-
},
5+
// Build using `docker buildx build dev` if image can't be found.
6+
"image": "local/base-gui:dev",
147
// Features to add to the dev container. More info: https://containers.dev/features.
158
"features": {
169
"ghcr.io/devcontainers/features/git:1": {},
@@ -19,11 +12,29 @@
1912
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2013
"forwardPorts": [
2114
4000
22-
]
15+
],
2316
// Uncomment the next line to run commands after the container is created.
2417
// "postCreateCommand": "cat /etc/os-release",
2518
// Configure tool-specific properties.
26-
// "customizations": {},
19+
"mounts": [
20+
{
21+
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.claude.json",
22+
"target": "/home/vscode/.claude.json",
23+
"type": "bind"
24+
},
25+
{
26+
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.claude",
27+
"target": "/home/vscode/.claude",
28+
"type": "bind"
29+
}
30+
],
31+
"customizations": {
32+
"vscode": {
33+
"extensions": [
34+
"Anthropic.claude-code"
35+
]
36+
}
37+
}
2738
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
2839
// "remoteUser": "devcontainer"
2940
}

.github/workflows/docker-publish.yml

Lines changed: 112 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,133 @@ name: Docker
33
on:
44
push:
55
branches:
6-
- master # Will be `dev`
6+
- master
77
tags:
8-
- v* # Publish `v1.2.3` tags as releases.
9-
10-
pull_request: # Run tests for any PRs.
11-
8+
- v*
129

1310
jobs:
14-
test: # See also https://docs.docker.com/docker-hub/builds/automated-testing/
11+
prepare:
1512
runs-on: ubuntu-latest
16-
13+
outputs:
14+
matrix: ${{ steps.filter.outputs.matrix }}
15+
targets: ${{ steps.targets.outputs.targets }}
1716
steps:
18-
- uses: actions/checkout@v2
19-
20-
- name: Run tests
17+
-
18+
name: Checkout
19+
uses: actions/checkout@v4
20+
-
21+
name: Generate matrix
22+
id: generate
23+
uses: docker/bake-action/subaction/matrix@v6
24+
with:
25+
fields: target,platforms
26+
-
27+
name: Filter matrix
28+
id: filter
29+
run: |
30+
matrix=$(echo '${{ steps.generate.outputs.matrix }}' | \
31+
jq -c '[.[] | select(.target | IN("novnc", "websockify", "dev") | not)]')
32+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
33+
-
34+
name: Extract unique targets
35+
id: targets
2136
run: |
22-
if [ -f docker-compose.test.yml ]; then
23-
docker-compose --file docker-compose.test.yml build
24-
docker-compose --file docker-compose.test.yml run sut
25-
else
26-
docker build --build-arg OS="debian:trixie-slim" --file Dockerfile .
27-
fi
37+
targets=$(echo '${{ steps.filter.outputs.matrix }}' | \
38+
jq -c '[.[].target] | unique')
39+
echo "targets=$targets" >> $GITHUB_OUTPUT
2840
2941
build:
30-
runs-on: ubuntu-latest
31-
32-
needs: test # Ensure test job passes before pushing image.
33-
if: github.event_name == 'push'
34-
permissions:
35-
contents: read
36-
packages: write
37-
42+
runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
43+
needs:
44+
- prepare
3845
strategy:
46+
fail-fast: false
3947
matrix:
40-
os: [bookworm-slim, bookworm, trixie, trixie-slim]
41-
include:
42-
- os: bookworm-slim
43-
image: debian:bookworm-slim
44-
- os: bookworm
45-
image: debian:bookworm
46-
- os: trixie-slim
47-
image: debian:trixie-slim
48-
- os: trixie
49-
image: debian:trixie
50-
48+
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
5149
steps:
52-
- name: Set up QEMU
53-
uses: docker/setup-qemu-action@v2
54-
55-
- name: Set up Docker Buildx
56-
uses: docker/setup-buildx-action@v2
57-
58-
- name: Dockerhub Login
59-
uses: docker/login-action@v1.10.0
50+
-
51+
name: Checkout
52+
uses: actions/checkout@v4
53+
-
54+
name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
-
57+
name: Dockerhub Login
58+
uses: docker/login-action@v3
6059
with:
6160
username: max06net
6261
password: ${{ secrets.DOCKERHUB_TOKEN }}
62+
-
63+
name: Build and push by digest
64+
id: build
65+
uses: docker/bake-action@v6
66+
with:
67+
targets: ${{ matrix.target }}
68+
set: |
69+
${{ matrix.target }}.platform=${{ matrix.platforms }}
70+
${{ matrix.target }}.tags=docker.io/max06net/base-gui
71+
${{ matrix.target }}.output=type=image,push-by-digest=true,name-canonical=true,push=true
72+
provenance: false
73+
-
74+
name: Export digest
75+
run: |
76+
mkdir -p ${{ runner.temp }}/digests
77+
digest=$(echo '${{ steps.build.outputs.metadata }}' | jq -r '."${{ matrix.target }}"."containerimage.digest"')
78+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
79+
-
80+
name: Upload digest
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: digests-${{ matrix.target }}-${{ startsWith(matrix.platforms, 'linux/arm') && 'arm64' || 'amd64' }}
84+
path: ${{ runner.temp }}/digests/*
85+
if-no-files-found: error
86+
retention-days: 1
6387

64-
- name: Docker meta
88+
merge:
89+
runs-on: ubuntu-latest
90+
needs:
91+
- prepare
92+
- build
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
target: ${{ fromJson(needs.prepare.outputs.targets) }}
97+
steps:
98+
-
99+
name: Download digests
100+
uses: actions/download-artifact@v4
101+
with:
102+
path: ${{ runner.temp }}/digests
103+
pattern: digests-${{ matrix.target }}-*
104+
merge-multiple: true
105+
-
106+
name: Dockerhub Login
107+
uses: docker/login-action@v3
108+
with:
109+
username: max06net
110+
password: ${{ secrets.DOCKERHUB_TOKEN }}
111+
-
112+
name: Set up Docker Buildx
113+
uses: docker/setup-buildx-action@v3
114+
-
115+
name: Docker meta
65116
id: meta
66-
uses: docker/metadata-action@v3
117+
uses: docker/metadata-action@v5
67118
with:
68-
images: max06net/base-gui
119+
images: docker.io/max06net/base-gui
69120
tags: |
70-
type=semver,pattern={{version}}-${{ matrix.os }}
71-
type=semver,pattern={{major}}.{{minor}}-${{ matrix.os }}
72-
type=semver,pattern={{major}}-${{ matrix.os }}
73-
type=edge,branch=master,suffix=-${{ matrix.os }}
74-
75-
- name: Build and push Docker images
76-
uses: docker/build-push-action@v4
77-
with:
78-
build-args: |
79-
OS=${{ !matrix.image && matrix.os || matrix.image }}
80-
# platforms: # optional
81-
pull: true
82-
push: true
83-
tags: ${{ steps.meta.outputs.tags }}
84-
labels: ${{ steps.meta.outputs.labels }}
85-
platforms: linux/amd64,linux/arm64
86-
# env:
87-
# OS: ${{ matrix.os }}
121+
type=semver,pattern={{version}},suffix=-${{ matrix.target }}
122+
type=semver,pattern={{major}}.{{minor}},suffix=-${{ matrix.target }}
123+
type=semver,pattern={{major}},suffix=-${{ matrix.target }}
124+
type=edge,branch=master,suffix=-${{ matrix.target }}
125+
-
126+
name: Create manifest list and push
127+
working-directory: ${{ runner.temp }}/digests
128+
run: |
129+
docker buildx imagetools create \
130+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
131+
$(printf 'docker.io/max06net/base-gui@sha256:%s ' *)
132+
-
133+
name: Inspect image
134+
run: |
135+
docker buildx imagetools inspect docker.io/max06net/base-gui:${{ steps.meta.outputs.version }}

.github/workflows/pull-request.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
prepare:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
matrix: ${{ steps.filter.outputs.matrix }}
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v4
15+
-
16+
name: Generate matrix
17+
id: generate
18+
uses: docker/bake-action/subaction/matrix@v6
19+
with:
20+
fields: target,platforms
21+
-
22+
name: Filter matrix
23+
id: filter
24+
run: |
25+
matrix=$(echo '${{ steps.generate.outputs.matrix }}' | \
26+
jq -c '[.[] | select(.target | IN("novnc", "websockify", "dev") | not)]')
27+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
28+
29+
validate:
30+
runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
31+
needs:
32+
- prepare
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
37+
steps:
38+
-
39+
name: Checkout
40+
uses: actions/checkout@v4
41+
42+
-
43+
name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
46+
-
47+
name: Dockerhub Login
48+
uses: docker/login-action@v3
49+
with:
50+
username: max06net
51+
password: ${{ secrets.DOCKERHUB_TOKEN }}
52+
53+
-
54+
name: Build and push by digest
55+
id: build
56+
if: endsWith(matrix.target, 'trixie-slim')
57+
uses: docker/bake-action@v6
58+
with:
59+
targets: ${{ matrix.target }}
60+
set: |
61+
${{ matrix.target }}.platform=${{ matrix.platforms }}
62+
${{ matrix.target }}.tags=docker.io/max06net/base-gui
63+
${{ matrix.target }}.output=type=image,push-by-digest=true,name-canonical=true,push=true
64+
provenance: false
65+
66+
-
67+
name: Build (cache only)
68+
if: "!endsWith(matrix.target, 'trixie-slim')"
69+
uses: docker/bake-action@v6
70+
with:
71+
targets: ${{ matrix.target }}
72+
set: |
73+
${{ matrix.target }}.platform=${{ matrix.platforms }}
74+
${{ matrix.target }}.output=type=cacheonly
75+
76+
-
77+
name: Export digest
78+
if: endsWith(matrix.target, 'trixie-slim')
79+
run: |
80+
mkdir -p ${{ runner.temp }}/digests
81+
digest=$(echo '${{ steps.build.outputs.metadata }}' | jq -r '."${{ matrix.target }}"."containerimage.digest"')
82+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
83+
84+
-
85+
name: Upload digest
86+
if: endsWith(matrix.target, 'trixie-slim')
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: digests-${{ matrix.target }}-${{ startsWith(matrix.platforms, 'linux/arm') && 'arm64' || 'amd64' }}
90+
path: ${{ runner.temp }}/digests/*
91+
if-no-files-found: error
92+
retention-days: 1
93+
94+
merge:
95+
runs-on: ubuntu-latest
96+
needs:
97+
- prepare
98+
- validate
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
target:
103+
- trixie-slim
104+
steps:
105+
-
106+
name: Download digests
107+
uses: actions/download-artifact@v4
108+
with:
109+
path: ${{ runner.temp }}/digests
110+
pattern: digests-${{ matrix.target }}-*
111+
merge-multiple: true
112+
113+
-
114+
name: Dockerhub Login
115+
uses: docker/login-action@v3
116+
with:
117+
username: max06net
118+
password: ${{ secrets.DOCKERHUB_TOKEN }}
119+
120+
-
121+
name: Set up Docker Buildx
122+
uses: docker/setup-buildx-action@v3
123+
124+
-
125+
name: Docker meta
126+
id: meta
127+
uses: docker/metadata-action@v5
128+
with:
129+
images: docker.io/max06net/base-gui
130+
tags: |
131+
type=ref,prefix=pr-,suffix=-${{ matrix.target }},event=pr
132+
133+
-
134+
name: Create manifest list and push
135+
working-directory: ${{ runner.temp }}/digests
136+
run: |
137+
docker buildx imagetools create \
138+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
139+
$(printf 'docker.io/max06net/base-gui@sha256:%s ' *)
140+
141+
-
142+
name: Inspect image
143+
run: |
144+
docker buildx imagetools inspect docker.io/max06net/base-gui:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)