Skip to content

Commit 3bd546c

Browse files
committed
move to 1 trivy location
1 parent b52430d commit 3bd546c

File tree

8 files changed

+30
-11
lines changed

8 files changed

+30
-11
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ RUN apt-get update && apt-get install -y \
33
jq \
44
&& apt-get clean \
55
&& 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_arm64 ARCH=ARM64 /tmp/install_trivy.sh
10-
RUN INSTALL_DIR=/tmp/trivy_amd64 ARCH=64bit /tmp/install_trivy.sh
6+
COPY src/base/.devcontainer/scripts/install_cosign.sh /tmp/install_cosign.sh
7+
COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh
8+
RUN case "${TARGETARCH}" in \
9+
x86_64|amd64) TRIVY_ARCH=64bit ;; \
10+
aarch64|arm64) TRIVY_ARCH=ARM64 ;; \
11+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
12+
esac \
13+
&& INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh
14+
1115

1216
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
1317
ARG TARGETARCH
@@ -75,7 +79,7 @@ RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \
7579
chmod 755 /usr/share/secrets-scanner && \
7680
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
7781

78-
COPY --from=build /tmp/trivy_${TARGETARCH}/trivy /usr/local/bin/trivy
82+
COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy
7983

8084
USER vscode
8185

.github/workflows/build_multi_arch_image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
fetch-depth: 0
6666
- name: setup trivy
6767
run: |
68-
docker build --output=/usr/local/bin/ -f "src/trivy/Dockerfile.${ARCH}" .
68+
docker build --output=/usr/local/bin/ -f "src/base/.devcontainer/Dockerfile.trivy.${ARCH}" .
6969
env:
7070
ARCH: '${{ matrix.arch }}'
7171
- name: setup node

src/base/.devcontainer/.tool-versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ shellcheck 0.11.0
22
direnv 2.37.1
33
actionlint 1.7.11
44
ruby 3.3.0
5-
trivy 0.69.3
65
yq 4.52.4

src/base/.devcontainer/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
FROM golang:1.26.1-bookworm AS build
2+
ARG TARGETARCH
3+
RUN apt-get update && apt-get install -y \
4+
jq \
5+
&& apt-get clean \
6+
&& rm -rf /var/lib/apt/lists/*
7+
COPY scripts/install_cosign.sh /tmp/install_cosign.sh
8+
COPY scripts/install_trivy.sh /tmp/install_trivy.sh
9+
RUN INSTALL_DIR=/usr/local/bin /tmp/install_cosign.sh
10+
RUN case "${TARGETARCH}" in \
11+
x86_64|amd64) TRIVY_ARCH=64bit ;; \
12+
aarch64|arm64) TRIVY_ARCH=ARM64 ;; \
13+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
14+
esac \
15+
&& INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh
16+
117
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
218

319
ARG SCRIPTS_DIR=/usr/local/share/eps
@@ -16,6 +32,8 @@ COPY --chmod=755 Mk ${SCRIPTS_DIR}/Mk
1632
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
1733
RUN ./root_install.sh
1834

35+
COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy
36+
1937
COPY --chmod=755 scripts/vscode_install.sh ${SCRIPTS_DIR}/${CONTAINER_NAME}/vscode_install.sh
2038
USER vscode
2139
COPY --chown=vscode:vscode .tool-versions.asdf /home/vscode/.tool-versions.asdf
File renamed without changes.
File renamed without changes.

scripts/install_cosign.sh renamed to src/base/.devcontainer/scripts/install_cosign.sh

File renamed without changes.

scripts/install_trivy.sh renamed to src/base/.devcontainer/scripts/install_trivy.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ INSTALL_DIR="${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}"
66
VERSION="v0.69.3"
77
DEFAULT_ARCH="64bit"
88
ARCH="${ARCH:-$DEFAULT_ARCH}"
9-
#trivy_0.69.3_Linux-64bit.tar.gz
10-
#trivy_0.69.3_Linux-ARM64.tar.gz
119
RELEASE_NUMBER="${VERSION#v}"
1210
BASE_URL="https://github.com/aquasecurity/trivy/releases/download/${VERSION}"
1311
ARCHIVE="trivy_${RELEASE_NUMBER}_Linux-${ARCH}.tar.gz"
@@ -18,7 +16,7 @@ usage() {
1816
cat <<'EOF'
1917
Usage: install_trivy.sh [output_dir]
2018
21-
Downloads Trivy v0.69.3, its sigstore bundle, and checksum into output_dir (default: current directory),
19+
Downloads Trivy, its sigstore bundle, and checksum into output_dir (default: current directory),
2220
then verifies the checksum and the sigstore bundle, following
2321
https://github.com/aquasecurity/trivy/blob/main/docs/getting-started/signature-verification.md.
2422
EOF

0 commit comments

Comments
 (0)