Skip to content

Commit 44a5b2f

Browse files
Merge Dockerfiles
1 parent d9c2ffb commit 44a5b2f

File tree

6 files changed

+161
-350
lines changed

6 files changed

+161
-350
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ build/
55
build_x86_64-linux-gnu/
66
serving/
77
tensorflow/
8+
*.eap

.github/actions/docker-build-push-action/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ runs:
7979
registry: ${{ inputs.registry }}
8080
username: ${{ inputs.registry_user }}
8181
password: ${{ inputs.registry_token }}
82-
- name: Build and push image to registry
82+
- name: Build image
8383
uses: docker/build-push-action@v6
8484
env:
8585
DOCKER_BUILD_SUMMARY: false

.github/workflows/ci-cd.yml

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,34 @@ on:
2424
- "main"
2525

2626
jobs:
27+
general_settings:
28+
name: Set general settings
29+
runs-on: ubuntu-latest
30+
outputs:
31+
EVENT_TYPE: ${{ steps.set_outputs.outputs.EVENT_TYPE }}
32+
SHORT_SHA: ${{ steps.set_outputs.outputs.SHORT_SHA }}
33+
steps:
34+
- name: get_trigger_event
35+
run: |
36+
eventtype=${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
37+
echo "EVENT_TYPE=${eventtype}" >> $GITHUB_ENV
38+
- name: get_short_sha
39+
run: |
40+
sha=${{ github.sha }}
41+
strip_sha=${sha:0:7}
42+
echo "SHORT_SHA=${strip_sha}" >> $GITHUB_ENV
43+
44+
- name: set_outputs
45+
id: set_outputs
46+
run: |
47+
echo "EVENT_TYPE=${{ env.EVENT_TYPE }}" >> $GITHUB_OUTPUT
48+
echo "SHORT_SHA=${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT
49+
2750
# Build and run the test suite
2851
build_and_test:
2952
name: Build and run test image
3053
runs-on: ubuntu-latest
54+
needs: general_settings
3155
strategy:
3256
fail-fast: false
3357
matrix:
@@ -59,11 +83,13 @@ jobs:
5983
- name: Build test image
6084
uses: ./.github/actions/docker-build-push-action
6185
with:
62-
dockerfile: Dockerfile.${{ matrix.arch }}
86+
dockerfile: Dockerfile
6387
tags: ${{ steps.meta_test.outputs.tags }}
6488
labels: ${{ steps.meta_test.outputs.labels }}
6589
push: true
66-
build-args: TEST=true
90+
build-args: |
91+
ARCH=${{ matrix.arch }}
92+
TEST=true
6793
target: runtime-base
6894
registry_user: ${{ secrets.ECOSYSTEM_SERVICE_USER_DOCKER_HUB }}
6995
registry_token: ${{ secrets.ECOSYSTEM_ACCESS_TOKEN_DOCKER_HUB }}
@@ -92,30 +118,26 @@ jobs:
92118
requirements_file: ./.github/test/requirements.txt
93119
logfile: test_log_${{ matrix.arch }}.txt
94120

95-
# Build base image and extract eap file then use ACAP portal to sign it
96-
# This job is skipped if not on main branch or if build_and_test job has failed
121+
# Build base image and extract eap file
97122
build:
98123
name: Build acap
99124
runs-on: ubuntu-latest
100-
needs: build_and_test
125+
needs: general_settings
101126
if: (github.event_name != 'pull_request')
102127
strategy:
103128
matrix:
104129
arch: [armv7hf, aarch64]
130+
env:
131+
EVENT_TYPE: ${{ needs.general_settings.outputs.EVENT_TYPE }}
132+
SHORT_SHA: ${{ needs.general_settings.outputs.SHORT_SHA }}
105133
outputs:
106134
EAP_FILE_ARMV7HF: ${{ steps.save_full_file_name.outputs.EAP_FILE_ARMV7HF }}
107135
EAP_FILE_AARCH64: ${{ steps.save_full_file_name.outputs.EAP_FILE_AARCH64 }}
108-
SHORT_SHA: ${{ steps.save_full_file_name.outputs.SHORT_SHA }}
109136
steps:
110137
- name: Checkout repo
111138
uses: actions/checkout@v4
112-
- name: get_short_sha
113-
run: |
114-
sha=${{ github.sha }}
115-
strip_sha=${sha:0:7}
116-
echo "SHORT_SHA=${strip_sha}" >> $GITHUB_ENV
117139
- uses: actions/cache@v4
118-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
140+
if: ${{ env.EVENT_TYPE }}
119141
with:
120142
path: ${{ github.workspace }}/build-${{ matrix.arch }}
121143
key: key-${{ env.SHORT_SHA }}-${{ github.run_id }}-${{ matrix.arch }}
@@ -128,7 +150,7 @@ jobs:
128150
get_version: "true"
129151
- name: Get changes for manifest
130152
id: manifest-settings
131-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
153+
if: ${{ env.EVENT_TYPE }}
132154
run: |
133155
if [ ${{github.ref_type}} == tag ]; then
134156
echo "version_value=${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
@@ -138,42 +160,43 @@ jobs:
138160
echo "append_sha='true'" >> $GITHUB_OUTPUT
139161
fi
140162
- name: Update manifest file
141-
if: ( github.ref_type == 'tag')
163+
if: ${{ env.EVENT_TYPE }}
142164
uses: ./.github/actions/update-acap-manifest-action
143165
with:
144166
manifest_file: ./manifest-${{ matrix.arch }}.json
145-
append: ${{ steps.manifest-settings.outputs.append_sha}}
167+
append: ${{ steps.manifest-settings.outputs.append_sha }}
146168
value: ${{ steps.manifest-settings.outputs.version_value }}
147-
- name: Build and push base image
169+
- name: Build eap file
148170
uses: ./.github/actions/docker-build-push-action
149171
with:
150-
dockerfile: Dockerfile.${{ matrix.arch }}
172+
dockerfile: Dockerfile
151173
tags: ${{ steps.meta.outputs.tags }}
152174
labels: ${{ steps.meta.outputs.labels }}
153-
target: runtime-base
175+
build-args: |
176+
ARCH=${{ matrix.arch }}
177+
target: binaries
154178
push: false
155179
load: true
180+
outputs: "type=local,dest=build"
156181
- name: Set name of EAP-file
157182
id: get_eap_file_name
158-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
183+
if: ${{ env.EVENT_TYPE }}
159184
run: |
160-
docker cp $(docker create "${{ steps.meta.outputs.full_name }}"):/opt/app .build
161-
export EAP_FILE=$(find .build -type f -name "*.eap" -printf "%f\n")
185+
export EAP_FILE=$(find build -type f -name "*.eap" -printf "%f\n")
162186
delimiter="$(openssl rand -hex 8)"
163187
echo "EAP_FILE<<${delimiter}" >> ${GITHUB_ENV}
164188
echo "${EAP_FILE}" >> ${GITHUB_ENV}
165189
echo "${delimiter}" >> ${GITHUB_ENV}
166190
- name: Add sha to EAP-file name
167-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
191+
if: ${{ env.EVENT_TYPE }}
168192
run: |
169193
eap_file_w_sha=$(echo $"${{ env.EAP_FILE }}" | sed 's/\.eap/_${{ env.SHORT_SHA }}.eap/')
170194
echo "EAP_FILE_W_SHA=${eap_file_w_sha}" >> $GITHUB_ENV
171195
cp build/${{ env.EAP_FILE }} build/$eap_file_w_sha
172196
- name: Save full file name
173197
id: save_full_file_name
174-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
198+
if: ${{ env.EVENT_TYPE }}
175199
run: |
176-
echo "SHORT_SHA=${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT
177200
if [ ${{ matrix.arch }} = armv7hf ]
178201
then
179202
echo "EAP_FILE_ARMV7HF=${{ env.EAP_FILE_W_SHA }}" >> $GITHUB_OUTPUT
@@ -184,28 +207,28 @@ jobs:
184207
echo "::error::Non valid architecture '${{ matrix.arch }}' encountered"
185208
fi
186209
- name: Move EAP-file to cache location
187-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
210+
if: ${{ env.EVENT_TYPE }}
188211
run: |
189212
mkdir -p ${{ github.workspace }}/build-${{ matrix.arch }}
190213
#rm -f ${{ github.workspace }}/build-${{ matrix.arch }}/${{ env.EAP_FILE_W_SHA }}
191214
mv build/${{ env.EAP_FILE_W_SHA }} ${{ github.workspace }}/build-${{ matrix.arch }}/.
192215
193-
# Sign the eap-file from the build
216+
# Sign the eap-file from the build step
194217
sign-eap:
195218
runs-on: ubuntu-latest
196-
if: ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
197-
needs: build
219+
needs: [general_settings, build]
220+
if: ${{ needs.general_settings.outputs.EVENT_TYPE }}
221+
env:
222+
EAP_FILE_ARMV7HF: ${{ needs.build.outputs.EAP_FILE_ARMV7HF }}
223+
EAP_FILE_AARCH64: ${{ needs.build.outputs.EAP_FILE_AARCH64 }}
224+
SHORT_SHA: ${{ needs.general_settings.outputs.SHORT_SHA }}
198225
permissions:
199226
contents: write
200227
strategy:
201228
fail-fast: false
202229
matrix:
203230
arch: ["armv7hf", "aarch64"]
204231
max-parallel: 1
205-
env:
206-
EAP_FILE_ARMV7HF: ${{ needs.build.outputs.EAP_FILE_ARMV7HF }}
207-
EAP_FILE_AARCH64: ${{ needs.build.outputs.EAP_FILE_AARCH64 }}
208-
SHORT_SHA: ${{ needs.build.outputs.SHORT_SHA }}
209232
outputs:
210233
EAP_FILE_SIGNED_ARMV7HF: ${{ steps.save_full_file_name.outputs.EAP_FILE_SIGNED_ARMV7HF }}
211234
EAP_FILE_SIGNED_AARCH64: ${{ steps.save_full_file_name.outputs.EAP_FILE_SIGNED_AARCH64 }}
@@ -236,7 +259,7 @@ jobs:
236259
echo "SIGNED_EAP_FILE=${signed_output}" >> $GITHUB_ENV
237260
- name: Sign eap-file
238261
run: |
239-
cd .build
262+
cd build
240263
RESPONSE=$(curl -XPOST -H 'accept: */*' -H 'Content-Type: multipart/form-data' \
241264
-H 'Authorization: Bearer ${{secrets.ACAP_PORTAL_SIGNING_BEARER_TOKEN}}' \
242265
'${{ vars.ACAP_PORTAL_URL }}/${{secrets.ACAP_PORTAL_SIGNING_ID}}/sign/binary' \
@@ -259,7 +282,7 @@ jobs:
259282
uses: actions/upload-artifact@v4
260283
with:
261284
name: ${{ env.SIGNED_EAP_FILE }}
262-
path: .build/${{ env.SIGNED_EAP_FILE }}
285+
path: build/${{ env.SIGNED_EAP_FILE }}
263286
if-no-files-found: error
264287
- name: Save file name
265288
id: save_full_file_name
@@ -275,12 +298,10 @@ jobs:
275298
fi
276299
277300
# Build containerized image and push to Docker Hub
278-
# This job is skipped if not on main branch or if build_and_test job has failed
279-
# It can (and should) run in parallel to the build_and_sign_acap job
280301
build_containerized:
281302
name: Build and push containerized images
282303
runs-on: ubuntu-latest
283-
needs: [build_and_test, build]
304+
needs: [general_settings, build_and_test, build]
284305
if: (github.event_name != 'pull_request')
285306
strategy:
286307
matrix:
@@ -304,7 +325,7 @@ jobs:
304325
- name: Build and push containerized image
305326
uses: ./.github/actions/docker-build-push-action
306327
with:
307-
dockerfile: Dockerfile.${{ matrix.arch }}
328+
dockerfile: Dockerfile
308329
tags: ${{ steps.meta_containerized.outputs.tags }}
309330
labels: ${{ steps.meta_containerized.outputs.labels }}
310331
push: true

0 commit comments

Comments
 (0)