Skip to content

Commit e2329ac

Browse files
committed
build trivy another way
1 parent 1b0e1f2 commit e2329ac

5 files changed

Lines changed: 25 additions & 41 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \
7474
mkdir -p /usr/share/secrets-scanner && \
7575
chmod 755 /usr/share/secrets-scanner && \
7676
curl -L https://raw.githubusercontent.com/NHSDigital/software-engineering-quality-framework/main/tools/nhsd-git-secrets/nhsd-rules-deny.txt -o /usr/share/secrets-scanner/nhsd-rules-deny.txt
77-
COPY --from=build /tmp/trivy_amd64/trivy /usr/local/bin/trivy
77+
78+
COPY --from=build /tmp/trivy_${TARGETARCH}/trivy /usr/local/bin/trivy
79+
7880
USER vscode
7981

8082
ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"

.github/workflows/build_all_images.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,9 @@ jobs:
3333
echo "node_24_languages=$node_24_language_folders"
3434
echo "projects=$project_folders"
3535
} >> "$GITHUB_OUTPUT"
36-
download_trivy:
37-
runs-on: ubuntu-latest
38-
steps:
39-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
40-
- name: Install cosign
41-
run: |
42-
./scripts/install_cosign.sh
43-
env:
44-
INSTALL_DIR: ${HOME}/.local/bin
45-
- name: Get amd64 trivy
46-
run: |
47-
./scripts/install_trivy.sh
48-
env:
49-
INSTALL_DIR: trivy_amd64
50-
ARCH: 64bit
51-
- name: Get arm64 trivy
52-
run: |
53-
./scripts/install_trivy.sh
54-
env:
55-
INSTALL_DIR: trivy_arm64
56-
ARCH: ARM64
57-
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
58-
name: Upload trivy
59-
with:
60-
name: "trivy"
61-
path: |
62-
trivy_amd64/trivy
63-
trivy_arm64/trivy
6436
6537
package_base_docker_image:
6638
uses: ./.github/workflows/build_multi_arch_image.yml
67-
needs: [
68-
download_trivy
69-
]
7039
with:
7140
tag_latest: ${{ inputs.tag_latest }}
7241
docker_tag: ${{ inputs.docker_tag }}

.github/workflows/build_multi_arch_image.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,11 @@ jobs:
6363
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
6464
with:
6565
fetch-depth: 0
66-
- name: Download trivy
67-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
68-
with:
69-
name: trivy
7066
- name: setup trivy
7167
run: |
72-
sudo cp "trivy/trivy_${ARCH}/trivy" /usr/local/bin/
73-
chmod +x /usr/local/bin/trivy
68+
docker build --output=/usr/local/bin/ -f "src/trivy/Dockerfile.${ARCH}" .
69+
env:
70+
ARCH: '${{ matrix.arch }}'
7471
- name: setup node
7572
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
7673
with:
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
FROM golang:1.26.1-bookworm
1+
FROM golang:1.26.1-bookworm AS build
22
RUN apt-get update && apt-get install -y \
33
jq \
44
&& apt-get clean \
55
&& rm -rf /var/lib/apt/lists/*
66
COPY scripts/install_cosign.sh /tmp/install_cosign.sh
77
COPY scripts/install_trivy.sh /tmp/install_trivy.sh
88
RUN INSTALL_DIR=/usr/local/bin /tmp/install_cosign.sh
9-
RUN INSTALL_DIR=trivy_arm64 ARCH=ARM64 /tmp/install_trivy.sh
10-
RUN INSTALL_DIR=trivy_amd64 ARCH=64bit /tmp/install_trivy.sh
9+
RUN INSTALL_DIR=/tmp/trivy/ ARCH=64bit /tmp/install_trivy.sh
10+
11+
FROM scratch
12+
COPY --from=build /tmp/trivy/trivy /
13+
ENTRYPOINT ["/trivy"]

src/trivy/Dockerfile.arm64

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:1.26.1-bookworm AS build
2+
RUN apt-get update && apt-get install -y \
3+
jq \
4+
&& apt-get clean \
5+
&& rm -rf /var/lib/apt/lists/*
6+
COPY scripts/install_cosign.sh /tmp/install_cosign.sh
7+
COPY scripts/install_trivy.sh /tmp/install_trivy.sh
8+
RUN INSTALL_DIR=/usr/local/bin /tmp/install_cosign.sh
9+
RUN INSTALL_DIR=/tmp/trivy/ ARCH=ARM64 /tmp/install_trivy.sh
10+
11+
FROM scratch
12+
COPY --from=build /tmp/trivy/trivy /
13+
ENTRYPOINT ["/trivy"]

0 commit comments

Comments
 (0)