Skip to content

Commit addb005

Browse files
authored
Merge pull request #472 from aahl/main
Add docker build workflow
2 parents 383b04a + f7f96a9 commit addb005

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.github/workflows/build.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Build Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: [main]
8+
9+
env:
10+
GITHUB_CR_REPO: ghcr.io/${{ github.repository }}
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
platform:
19+
- linux/amd64
20+
- linux/arm64
21+
steps:
22+
- name: Prepare
23+
run: |
24+
platform=${{ matrix.platform }}
25+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
26+
27+
- name: Docker meta
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: |
32+
${{ env.GITHUB_CR_REPO }}
33+
34+
- name: Login to GHCR
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.repository_owner }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Build and push by digest
48+
id: build
49+
uses: docker/build-push-action@v6
50+
with:
51+
platforms: ${{ matrix.platform }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
tags: |
54+
${{ env.GITHUB_CR_REPO }}
55+
build-args: |
56+
TARGETPLATFORM=${{ matrix.platform }}
57+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
58+
59+
- name: Export digest
60+
run: |
61+
mkdir -p ${{ runner.temp }}/digests
62+
digest="${{ steps.build.outputs.digest }}"
63+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
64+
65+
- name: Upload digest
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: digests-${{ env.PLATFORM_PAIR }}
69+
path: ${{ runner.temp }}/digests/*
70+
if-no-files-found: error
71+
retention-days: 1
72+
73+
merge:
74+
runs-on: ubuntu-latest
75+
needs:
76+
- build
77+
steps:
78+
- name: Download digests
79+
uses: actions/download-artifact@v4
80+
with:
81+
path: ${{ runner.temp }}/digests
82+
pattern: digests-*
83+
merge-multiple: true
84+
85+
- name: Login to GHCR
86+
uses: docker/login-action@v3
87+
with:
88+
registry: ghcr.io
89+
username: ${{ github.repository_owner }}
90+
password: ${{ secrets.GITHUB_TOKEN }}
91+
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v3
94+
95+
- name: Docker meta
96+
id: meta
97+
uses: docker/metadata-action@v5
98+
with:
99+
images: |
100+
${{ env.GITHUB_CR_REPO }}
101+
tags: |
102+
type=ref,event=branch
103+
type=ref,event=pr
104+
type=semver,pattern={{version}}
105+
type=semver,pattern={{major}}
106+
107+
- name: Docker tags
108+
run: |
109+
tags=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
110+
if [ -z "$tags" ]; then
111+
echo "DOCKER_METADATA_OUTPUT_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
112+
tags="-t ${{ env.GITHUB_CR_REPO }}:${{ github.ref_name }}"
113+
fi
114+
echo "DOCKER_METADATA_TAGS=$tags" >> $GITHUB_ENV
115+
116+
- name: Create manifest list and push
117+
working-directory: ${{ runner.temp }}/digests
118+
run: |
119+
docker buildx imagetools create ${{ env.DOCKER_METADATA_TAGS }} \
120+
$(printf '${{ env.GITHUB_CR_REPO }}@sha256:%s ' *)
121+
122+
- name: Inspect image
123+
run: |
124+
docker buildx imagetools inspect ${{ env.GITHUB_CR_REPO }}:${{ env.DOCKER_METADATA_OUTPUT_VERSION }}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
# debug: docker compose run --rm -it browser-use-webui bash
33
browser-use-webui:
4+
# image: ghcr.io/browser-use/web-ui # Using precompiled image
45
build:
56
context: .
67
dockerfile: Dockerfile

0 commit comments

Comments
 (0)