-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (233 loc) · 10.4 KB
/
build-env-container.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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# Copyright (C) 2023 Martin Scheiber,
# Control of Networked Systems, University of Klagenfurt, Austria.
#
# All rights reserved.
#
# This software is licensed under the terms of the BSD-2-Clause-License with
# no commercial use allowed, the full terms of which are made available
# in the LICENSE file. No license in patents is granted.
#
# You can contact the author at <[email protected]>.
name: Skiff Container Build
on:
push:
branches: [ "main", "develop" ]
paths:
- 'common/rootfs_part/coreenv/flightstack/**'
- '.github/workflows/build-env-container.yml'
jobs:
##############################################################################
# Filter changed paths
# from https://stackoverflow.com/questions/70708306/github-actions-run-step-job-in-a-workflow-if-changes-happen-in-specific-folde?rq=1
paths-filter:
name: Changed File Filter
runs-on: ubuntu-latest
outputs:
base: ${{ steps.filter.outputs.base }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
# check if any relevant files for base image have changed (otherwise no need to recompile base)
- name: Check Base Change
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
base:
- '.github/workflows/build-env-container.yml'
- 'common/rootfs_part/coreenv/flightstack/Dockerfile.base'
- 'common/rootfs_part/coreenv/flightstack/etc/**'
- 'common/rootfs_part/coreenv/flightstack/home/**'
- 'common/rootfs_part/coreenv/flightstack/init_scripts/**'
##############################################################################
# Build Latest Containers
build_container_latest:
name: Build Flightstack Container (main - ${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }})
needs: paths-filter
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [noetic, melodic]
UNIX_BASE:
- ubuntu:bionic
- ubuntu:focal
include:
- UNIX_BASE: ubuntu:bionic
UNIX_SHORT: ubionic
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
- UNIX_BASE: ubuntu:focal
UNIX_SHORT: ufocal
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
exclude:
- UNIX_BASE: ubuntu:bionic
ROS_DISTRO: noetic
- UNIX_BASE: ubuntu:focal
ROS_DISTRO: melodic
env:
# IMAGE_URL: ${{ secrets.GITLAB_REGISTRY_IMAGE_URL }}
# IMAGE_NAME: flight_stack
IMAGE_URL: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
IMAGE_NAME: flightstack
COMMIT_HASH: ${{ github.sha }}
LATEST_ROS: noetic
LATEST_UNIX: ubuntu:focal
GIT_VERSION: 1.0.0-rc1
steps:
- name: Get current date
id: date
run: echo "date=$(date '+%F-%H-%M-%S')" >> $GITHUB_OUTPUT
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKERHUB_REGISTRY_USER}}
password: ${{secrets.DOCKERHUB_REGISTRY_PASSWORD}}
# registry: ${{secrets.GITLAB_REGISTRY_URL}}
########################
### BUILD LATEST IMAGES
- name: Build Base Image (latest)
if: ${{ matrix.ROS_DISTRO == env.LATEST_ROS && matrix.UNIX_BASE == env.LATEST_UNIX && needs.paths-filter.outputs.base == 'true' }}
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:latest \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:${COMMIT_HASH::7} \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }} \
--build-arg VERSION="${GIT_VERSION}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--build-arg ROS_BUILD_DISTRO="${{ matrix.ROS_DISTRO }}" \
--build-arg UNIX_BASE="${{ matrix.UNIX_BASE }}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile.base \
./common/rootfs_part/coreenv/flightstack/
- name: Build Skiff Image (latest)
if: ${{ matrix.ROS_DISTRO == env.LATEST_ROS && matrix.UNIX_BASE == env.LATEST_UNIX }}
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:latest \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${COMMIT_HASH::7} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }} \
--build-arg BASE_REGISTRY="${IMAGE_URL}/${IMAGE_NAME}-base" \
--build-arg BASE_TAG="latest" \
--build-arg VERSION="${GIT_VERSION}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile \
./common/rootfs_part/coreenv/flightstack/
########################
### BUILD OTHER IMAGES
- name: Build Base Image (${{ matrix.UNIX_BASE }} with ROS-${{ matrix.ROS_DISTRO }})
if: ${{ (matrix.ROS_DISTRO != env.LATEST_ROS || matrix.UNIX_BASE != env.LATEST_UNIX) && needs.paths-filter.outputs.base == 'true' }}
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }} \
--build-arg VERSION="${GIT_VERSION}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--build-arg ROS_BUILD_DISTRO="${{ matrix.ROS_DISTRO }}" \
--build-arg UNIX_BASE="${{ matrix.UNIX_BASE }}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile.base \
./common/rootfs_part/coreenv/flightstack/
- name: Build Skiff Image (${{ matrix.UNIX_BASE }} with ROS-${{ matrix.ROS_DISTRO }})
if: ${{ matrix.ROS_DISTRO != env.LATEST_ROS || matrix.UNIX_BASE != env.LATEST_UNIX }}
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }} \
--build-arg BASE_REGISTRY="${IMAGE_URL}/${IMAGE_NAME}-base" \
--build-arg BASE_TAG="${{ matrix.UNIX_SHORT }}_${{ matrix.ROS_DISTRO }}" \
--build-arg VERSION="${GIT_VERSION}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile \
./common/rootfs_part/coreenv/flightstack/
##############################################################################
# Build Ddv Containers
build_container_dev:
name: Build Flightstack Dev Container (${{ github.ref_name }})
needs: paths-filter
if: ${{ github.ref_name != 'main' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
UNIX_BASE:
- ubuntu:focal
include:
- UNIX_BASE: ubuntu:focal
UNIX_SHORT: dev
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
env:
# IMAGE_URL: ${{ secrets.GITLAB_REGISTRY_IMAGE_URL }}
# IMAGE_NAME: flight_stack
IMAGE_URL: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
IMAGE_NAME: flightstack
COMMIT_HASH: ${{ github.sha }}
ROS_DISTRO: noetic
UNIX_BASE: ubuntu:focal
steps:
- name: Get current date
id: date
run: echo "date=$(date '+%F-%H-%M-%S')" >> $GITHUB_OUTPUT
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKERHUB_REGISTRY_USER}}
password: ${{secrets.DOCKERHUB_REGISTRY_PASSWORD}}
# registry: ${{secrets.GITLAB_REGISTRY_URL}}
- name: Build Base Image (${{ matrix.UNIX_SHORT }})
if : ${{ needs.paths-filter.outputs.base == 'true' }}
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:${{ matrix.UNIX_SHORT }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}-base:${COMMIT_HASH::7} \
--build-arg VERSION="${COMMIT_HASH::7}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--build-arg ROS_BUILD_DISTRO="${ROS_DISTRO}" \
--build-arg UNIX_BASE="${{ matrix.UNIX_BASE }}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile.base \
./common/rootfs_part/coreenv/flightstack/
- name: Build Skiff Image (${{ matrix.UNIX_SHORT }})
env:
BUILD_TIMESTAMP: ${{ steps.date.outputs.date }}
run: >
docker buildx build \
--platform=${{ matrix.PLATFORMS }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${{ matrix.UNIX_SHORT }} \
--tag ${IMAGE_URL}/${IMAGE_NAME}:${COMMIT_HASH::6} \
--build-arg BASE_REGISTRY="${IMAGE_URL}/${IMAGE_NAME}-base" \
--build-arg BASE_TAG="${{ matrix.UNIX_SHORT }}" \
--build-arg VERSION="${COMMIT_HASH::6}" \
--build-arg BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" \
--compress --force-rm --push \
-f ./common/rootfs_part/coreenv/flightstack/Dockerfile \
./common/rootfs_part/coreenv/flightstack/