-
-
Notifications
You must be signed in to change notification settings - Fork 20
199 lines (177 loc) · 7.83 KB
/
dockerimage.yml
File metadata and controls
199 lines (177 loc) · 7.83 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
196
197
198
199
name: build
on:
push:
branches:
tags:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'
- '.github/dependabot.yml'
- '.github/FUNDING.yml'
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'
- '.github/dependabot.yml'
- '.github/FUNDING.yml'
jobs:
build_app_image:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3
- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}
- name: build base.app image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build base.alpine -f base.alpine/Dockerfile
- name: build and push master base.app image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/app:${ref} -t ${USERNAME}/baseimage:app-${ref} \
base.alpine -f base.alpine/Dockerfile
- name: build and push tagged base.app latest image
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/app:${ref} -t ${USERNAME}/baseimage:app-${ref} \
-t ghcr.io/${USERNAME}/baseimage/app:latest -t ${USERNAME}/baseimage:app-latest \
base.alpine -f base.alpine/Dockerfile
build_go_image:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3
- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}
- name: build build.go image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build build.go -f build.go/Dockerfile
- name: build and push master build.go image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/buildgo:${ref} -t ${USERNAME}/baseimage:buildgo-${ref} \
build.go -f build.go/Dockerfile
- name: build build.go latest image
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/buildgo:${ref} -t ${USERNAME}/baseimage:buildgo-${ref} \
-t ghcr.io/${USERNAME}/baseimage/buildgo:latest -t ${USERNAME}/baseimage:buildgo-latest \
build.go -f build.go/Dockerfile
build_scratch_image:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3
- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}
- name: build base.scratch image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build base.scratch -f base.scratch/Dockerfile
- name: build and push master base.scratch image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/scratch:${ref} -t ${USERNAME}/baseimage:scratch-${ref} \
base.scratch -f base.scratch/Dockerfile
- name: build base.scratch latest image
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/scratch:${ref} -t ${USERNAME}/baseimage:scratch-${ref} \
-t ghcr.io/${USERNAME}/baseimage/scratch:latest -t ${USERNAME}/baseimage:scratch-latest \
base.scratch -f base.scratch/Dockerfile