-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathbuild-docker-images-for-testing.yml
More file actions
74 lines (66 loc) · 2.75 KB
/
build-docker-images-for-testing.yml
File metadata and controls
74 lines (66 loc) · 2.75 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
name: "Build Docker Images For Testing"
on:
# inspired by https://github.com/orgs/community/discussions/26801 we take the runs-on as parameter so we can run arm64 on native hardwarde
workflow_dispatch:
inputs:
platform:
type: string
default: "linux/amd64"
workflow_call:
inputs:
platform:
type: string
default: "linux/amd64"
jobs:
build:
name: Build Docker Images
runs-on: ${{ inputs.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
matrix:
# integration tests are only build (and run) on debian linux/amd64
docker-image: [django, nginx, integration-tests]
os: [alpine, debian]
platform: ["${{ inputs.platform }}"]
exclude:
- docker-image: nginx
os: debian
- docker-image: integration-tests
os: alpine
- docker-image: integration-tests
platform: linux/arm64
steps:
# Replace slashes so we can use this in filenames
- name: Set-platform
run: |
platform=${{ inputs.platform }}
echo "PLATFORM=${platform//\//-}" >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Read Docker Image Identifiers
id: read-docker-image-identifiers
run: echo "IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Build
id: docker_build
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
timeout-minutes: 15
env:
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
with:
context: .
push: false
tags: defectdojo/defectdojo-${{ matrix.docker-image }}:${{ matrix.os }},${{ env.IMAGE_REPOSITORY }}/defectdojo-${{ matrix.docker-image }}:${{ matrix.os }}
file: Dockerfile.${{ matrix.docker-image }}-${{ matrix.os }}
outputs: type=docker,dest=${{ matrix.docker-image }}-${{ matrix.os }}-${{ env.PLATFORM }}_img
# export docker images to be used in next jobs below
- name: Upload image ${{ matrix.docker-image }} as artifact
timeout-minutes: 15
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: built-docker-image-${{ matrix.docker-image }}-${{ matrix.os }}-${{ env.PLATFORM }}
path: ${{ matrix.docker-image }}-${{ matrix.os }}-${{ env.PLATFORM }}_img
retention-days: 1