-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (173 loc) · 6.88 KB
/
docker-build.yml
File metadata and controls
195 lines (173 loc) · 6.88 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Docker build & push
on:
push:
branches: [main, master]
tags: ["v*"]
pull_request:
branches: [main, master]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
# ============================================
# API Dependencies (cached node_modules)
# ============================================
api-deps:
name: API deps (cached node_modules)
runs-on: ubuntu-24.04-arm
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Lowercase owner for GHCR
id: owner
run: echo "owner_lc=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push deps (builder)
uses: docker/build-push-action@v6
with:
context: ./api
file: ./api/Dockerfile.deps
target: deps-builder
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:builder
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:builder-sha-${{ github.sha }}
cache-from: type=gha,scope=api-deps-builder
cache-to: type=gha,mode=max,scope=api-deps-builder
- name: Build and push deps (production)
uses: docker/build-push-action@v6
with:
context: ./api
file: ./api/Dockerfile.deps
target: deps-production
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:production
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:production-sha-${{ github.sha }}
cache-from: type=gha,scope=api-deps-production
cache-to: type=gha,mode=max,scope=api-deps-production
# ============================================
# API Application
# ============================================
api:
name: API app
runs-on: ubuntu-24.04-arm
needs: [api-deps]
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Lowercase owner for GHCR
id: owner
run: echo "owner_lc=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
type=semver,pattern={{version}}
type=sha,prefix=sha-,format=short
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./api
file: ./api/Dockerfile
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDER_DEPS_IMAGE=ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:builder
PRODUCTION_DEPS_IMAGE=ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api-deps:production
cache-from: type=gha,scope=api-app
cache-to: type=gha,mode=max,scope=api-app
# ============================================
# Web Application
# ============================================
web:
name: Web app
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Lowercase owner for GHCR
id: owner
run: echo "owner_lc=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-web
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
type=semver,pattern={{version}}
type=sha,prefix=sha-,format=short
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./web
file: ./web/Dockerfile
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=web-app
cache-to: type=gha,mode=max,scope=web-app
# ============================================
# Deployment Summary
# ============================================
summary:
name: Deployment summary
needs: [api, web]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Lowercase owner for GHCR
id: owner
run: echo "owner_lc=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Generate summary
run: |
echo "## 🚀 Images Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### API" >> $GITHUB_STEP_SUMMARY
echo "- \`ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api:latest\`" >> $GITHUB_STEP_SUMMARY
echo "- \`ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-api:sha-${GITHUB_SHA::7}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Web" >> $GITHUB_STEP_SUMMARY
echo "- \`ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-web:latest\`" >> $GITHUB_STEP_SUMMARY
echo "- \`ghcr.io/${{ steps.owner.outputs.owner_lc }}/finkit-web:sha-${GITHUB_SHA::7}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Deploy" >> $GITHUB_STEP_SUMMARY
echo "Run \`./deploy.sh\` on your Raspberry Pi to update." >> $GITHUB_STEP_SUMMARY