|
1 | | -name: Multi-arch build |
| 1 | +name: Docker Build Test |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
5 | 12 | paths-ignore: |
6 | 13 | - '**.md' |
7 | 14 |
|
8 | | -env: |
9 | | - IMAGE_TAG: latest |
10 | | - IMAGE_REGISTRY: quay.io |
11 | | - IMAGE_REPOSITORY: crowdstrike/detection-container |
| 15 | +permissions: |
| 16 | + contents: read |
12 | 17 |
|
13 | 18 | jobs: |
14 | | - build-multiarch-image: |
15 | | - name: Build multi-architecture image |
| 19 | + docker-build-test: |
16 | 20 | runs-on: ubuntu-latest |
17 | | - permissions: |
18 | | - contents: read |
19 | | - |
| 21 | + timeout-minutes: 20 |
20 | 22 | steps: |
21 | | - - name: Install qemu dependency |
22 | | - run: | |
23 | | - sudo apt-get update |
24 | | - sudo apt-get install -y qemu-user-static |
25 | | -
|
26 | | - - name: Checkout project |
| 23 | + - name: Checkout code |
27 | 24 | uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
28 | 25 |
|
29 | | - - name: Set up QEMU |
30 | | - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
31 | | - |
32 | 26 | - name: Set up Docker Buildx |
33 | 27 | uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
34 | | - with: |
35 | | - platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le |
36 | | - |
37 | | - - name: Login to Docker Hub |
38 | | - uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
39 | | - with: |
40 | | - registry: ${{ env.IMAGE_REGISTRY }} |
41 | | - username: ${{ secrets.REGISTRY_LOGIN }} |
42 | | - password: ${{ secrets.REGISTRY_PASSWORD }} |
43 | 28 |
|
44 | | - - name: Build and push |
45 | | - id: build_image_multiarch |
| 29 | + - name: Build multi-platform Docker image |
46 | 30 | uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
47 | 31 | with: |
48 | 32 | context: . |
49 | | - file: ./Dockerfile |
50 | | - platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le |
51 | | - push: true |
| 33 | + platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le |
| 34 | + push: false |
| 35 | + cache-from: type=gha |
| 36 | + cache-to: type=gha,mode=max |
52 | 37 | tags: | |
53 | | - ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }} |
| 38 | + detection-container:test |
| 39 | + detection-container:pr-${{ github.event.pull_request.number }} |
54 | 40 |
|
55 | | - - name: Check manifest |
| 41 | + - name: Test Docker image (amd64) |
56 | 42 | run: | |
57 | | - docker buildx imagetools inspect ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }} |
| 43 | + docker buildx build \ |
| 44 | + --platform linux/amd64 \ |
| 45 | + --load \ |
| 46 | + --tag detection-container:test-local \ |
| 47 | + . |
| 48 | +
|
| 49 | + echo "Testing container starts successfully..." |
| 50 | + docker run --rm detection-container:test-local echo ok |
| 51 | +
|
| 52 | + echo "Docker image smoke tests passed!" |
0 commit comments