-
-
Notifications
You must be signed in to change notification settings - Fork 369
158 lines (141 loc) · 5.02 KB
/
docker.yml
File metadata and controls
158 lines (141 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Docker
on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "*"
env:
# Docker & Registries
ARCHITECTURES: linux/arm64,linux/amd64,linux/arm/v7
IMAGE_NAME: silverbullet
WEBSITE_IMAGE: zefhemel/silverbullet-website
NAMESPACE_GITHUB: silverbulletmd
NAMESPACE_DOCKER: zefhemel
jobs:
docker-main:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Set up QEMU for multi-arch builds with buildx
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.ARCHITECTURES }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: ${{ env.ARCHITECTURES }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the ghcr Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.25.1"
- name: Install dependencies
run: npm ci
- name: Build binaries for multiple platforms
run: |
make build-for-docker
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.4.0
with:
images: |
# Set the different image names(paces) for docker-hub & ghcr
${{ env.NAMESPACE_DOCKER }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ env.NAMESPACE_GITHUB }}/${{ env.IMAGE_NAME }}
tags: |
# When pushing a tag, release a tagged release :x.x.x
type=semver,pattern={{raw}},enable=true
# When pushing a tag (type=semver) push to :latest too
type=semver,pattern=latest,enable=true
# When pushing to main branch, release as :edge DISABLED FOR NOW
# type=edge,branch=main
# When pushing to main branch, release as :v2
type=raw,value=v2,enable=${{ github.ref == 'refs/heads/main' }}
- name: Build and push main docker images
uses: docker/build-push-action@v6.18.0
with:
context: .
platforms: ${{ env.ARCHITECTURES }}
push: true
file: Dockerfile.ci
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Runtime API: Extract metadata"
id: rc_meta
uses: docker/metadata-action@v4.4.0
with:
images: |
${{ env.NAMESPACE_DOCKER }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ env.NAMESPACE_GITHUB }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{raw}}-runtime-api,enable=true
type=semver,pattern=latest,value=latest-runtime-api,enable=true
type=raw,value=v2-runtime-api,enable=${{ github.ref == 'refs/heads/main' }}
- name: "Runtime API: Build and push"
uses: docker/build-push-action@v6.18.0
with:
context: .
platforms: ${{ env.ARCHITECTURES }}
push: true
file: Dockerfile.ci.runtime-api
provenance: false
build-args: |
BASE_IMAGE=ghcr.io/${{ env.NAMESPACE_GITHUB }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
tags: ${{ steps.rc_meta.outputs.tags }}
labels: ${{ steps.rc_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
docker-website:
runs-on: ubuntu-latest
# Wait for main image so the base image is available (especially for release tags)
needs: docker-main
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Website: Extract metadata (tags, labels) for docker"
id: website_meta
uses: docker/metadata-action@v4.4.0
with:
images: ${{ env.WEBSITE_IMAGE }}
tags: |
type=edge,branch=main
type=semver,pattern=latest,enable=true
- name: "Website: Build and push"
uses: docker/build-push-action@v6.18.0
with:
context: .
file: Dockerfile.website
push: true
provenance: false
build-args: |
BASE_IMAGE=zefhemel/silverbullet:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || 'v2' }}
tags: ${{ steps.website_meta.outputs.tags }}
labels: ${{ steps.website_meta.outputs.labels }}