Skip to content

Commit c77122b

Browse files
committed
Add Docker build and publish workflows
1 parent 11f480b commit c77122b

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Docker Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v5
13+
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
with:
17+
version: latest
18+
buildkitd-flags: --debug
19+
20+
- name: Cache Docker layers
21+
uses: actions/cache@v4
22+
with:
23+
path: ${{ runner.temp }}/.buildx-cache
24+
key: ${{ runner.os }}-buildx-${{ github.sha }}
25+
restore-keys: |
26+
${{ runner.os }}-buildx-
27+
28+
- name: Build
29+
run: |
30+
buildx build -t kratos-selfservice-wasm:latest \
31+
--cache-from type=local,src=${{ runner.temp }}/.buildx-cache \
32+
--cache-to type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max .
33+
34+
- name: Move cache
35+
run: |
36+
rm -rf ${{ runner.temp }}/.buildx-cache
37+
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Docker Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
version_tag:
10+
description: 'Version tag'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Docker meta
19+
id: meta
20+
uses: docker/metadata-action@v5
21+
with:
22+
# list of Docker images to use as base name for tags
23+
images: |
24+
jeseng/kratos-selfservice-wasm
25+
# generate Docker tags based on the following events/attributes
26+
tags: |
27+
type=schedule
28+
type=ref,event=branch
29+
type=ref,event=pr
30+
type=semver,pattern={{version}}
31+
type=semver,pattern={{major}}.{{minor}}
32+
type=semver,pattern={{major}}
33+
type=sha
34+
35+
- name: Login to Docker Hub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ vars.DOCKERHUB_USERNAME }}
39+
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
43+
with:
44+
version: latest
45+
46+
- name: Validate build configuration
47+
uses: docker/build-push-action@v6
48+
with:
49+
call: check
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v6
53+
with:
54+
push: true
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)