-
-
Notifications
You must be signed in to change notification settings - Fork 57
105 lines (92 loc) · 3.42 KB
/
build_and_push.yml
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
name: Build and Push
on:
push:
release:
types: [published]
jobs:
build_and_push:
runs-on: ubuntu-24.04
name: "Build and Push (${{ matrix.services.service_name }})"
strategy:
fail-fast: true
matrix:
services:
-
service_name: app
dockerfile: docker-app/Dockerfile
docker_context: docker-app
docker_target: webserver_runtime
enable_dockerhub: true
-
service_name: app-test
dockerfile: docker-app/Dockerfile
docker_context: docker-app
docker_target: webserver_test
enable_dockerhub: false
-
service_name: worker-wrapper
dockerfile: docker-app/Dockerfile
docker_context: docker-app
docker_target: worker_wrapper_runtime
enable_dockerhub: true
-
service_name: qgis
dockerfile: docker-qgis/Dockerfile
docker_context: docker-qgis
enable_dockerhub: true
-
service_name: nginx
dockerfile: docker-nginx/Dockerfile
docker_context: docker-nginx
enable_dockerhub: true
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker Metadata
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: |
name=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }},enable=true
name=opengisch/qfieldcloud-${{ matrix.services.service_name }},enable=${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }}
flavor: |
latest=auto
prefix=,onlatest=false
suffix=
tags: |
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr
type=sha,format=short,prefix=commit-,event=pr
type=semver,pattern={{version}},event=release
type=edge,branch=main
-
name: Login to GitHub Container Repository (ghcr.io)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Login to Docker Hub
if: ${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
-
name: Docker Build ${{ matrix.services.service_name }}
id: docker_test_application
uses: docker/build-push-action@v6
with:
file: ${{ matrix.services.dockerfile }}
context: ${{ matrix.services.docker_context }}
push: ${{ matrix.services.enable_dockerhub && (github.event_name == 'release' || github.ref_name == 'master') }}
target: ${{ matrix.services.docker_target }}
tags: ${{ steps.docker_metadata.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }}:buildcache
cache-to: type=registry,ref=ghcr.io/opengisch/qfieldcloud-${{ matrix.services.service_name }}:buildcache,mode=max