-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (154 loc) · 5.1 KB
/
build-images.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
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
#
name: Create and publish a Docker image
# Configures this workflow to run every time a change is pushed to the branch called `main`.
on:
push:
branches:
- 'main'
tags:
- 'v*'
# Defines two custom environment variables for the workflow. These are used for
# the Container registry domain, and a name for the Docker image that this
# workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_BASE: photodirs
# There is a single job in this workflow. It's configured to run on the latest
# available version of Ubuntu.
jobs:
build-and-push-image:
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
#
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-node@v4
with:
node-version: '18'
# Generate the default config (port 3333, admin=true)
- run: bin/gen-config
# Uses the `docker/login-action` action to log in to the Container
# registry registry using the account and password that will publish the
# packages. Once published, the packages are scoped to the account
# defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
## NGINX CONTAINER
- name: nginx Docker meta
id: nginx_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/zsteinkamp/${{ env.IMAGE_BASE }}-nginx
tags: |
type=raw,value=latest
type=sha
- name: nginx Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./Dockerfile.nginx
context: .
push: true
tags: ${{ steps.nginx_meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.nginx_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
## FRONTEND CONTAINER
- name: frontend Docker meta
id: frontend_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/zsteinkamp/${{ env.IMAGE_BASE }}-frontend
tags: |
type=raw,value=latest
type=sha
- name: frontend Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./frontend/Dockerfile.gh
context: frontend/
target: prod
push: true
tags: ${{ steps.frontend_meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.frontend_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
## API CONTAINER
- name: api Docker meta
id: api_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/zsteinkamp/${{ env.IMAGE_BASE }}-api
tags: |
type=raw,value=latest
type=sha
- name: api Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile.gh
context: backend/
target: api
push: true
tags: ${{ steps.api_meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.api_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
## WATCHER CONTAINER
- name: watcher Docker meta
id: watcher_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/zsteinkamp/${{ env.IMAGE_BASE }}-watcher
tags: |
type=raw,value=latest
type=sha
- name: watcher Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile.gh
context: backend/
target: watcher
push: true
tags: ${{ steps.watcher_meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.watcher_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
## ADMIN CONTAINER
- name: admin Docker meta
id: admin_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/zsteinkamp/${{ env.IMAGE_BASE }}-admin
tags: |
type=raw,value=latest
type=sha
- name: admin Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile.gh
context: backend/
target: admin
push: true
tags: ${{ steps.admin_meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
labels: ${{ steps.admin_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max