|
1 | | -FROM alpine:3.23.3 AS build |
2 | | -ARG TARGETARCH |
3 | | -RUN apk add --no-cache cosign bash curl jq |
4 | | -COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh |
5 | | -RUN case "${TARGETARCH}" in \ |
6 | | - x86_64|amd64) TRIVY_ARCH=64bit ;; \ |
7 | | - aarch64|arm64) TRIVY_ARCH=ARM64 ;; \ |
8 | | - *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \ |
9 | | - esac \ |
10 | | - && INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh |
11 | | - |
12 | | - |
13 | | -FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 |
14 | | -ARG TARGETARCH |
15 | | -ENV TARGETARCH=${TARGETARCH} |
16 | | - |
17 | | -# Install essential packages first |
18 | | -RUN apt-get update && apt-get install -y \ |
19 | | - curl \ |
20 | | - wget \ |
21 | | - git \ |
22 | | - sudo \ |
23 | | - unzip \ |
24 | | - && apt-get clean \ |
25 | | - && rm -rf /var/lib/apt/lists/* |
26 | | - |
27 | | -# Copy ASDF version file |
28 | | -ARG ASDF_VERSION |
29 | | -COPY .tool-versions.asdf /tmp/.tool-versions.asdf |
30 | | - |
31 | | -# Add amd64 architecture if on arm64 |
32 | | -RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi |
33 | | - |
34 | | -RUN apt-get update \ |
35 | | - && export DEBIAN_FRONTEND=noninteractive \ |
36 | | - && apt-get -y dist-upgrade \ |
37 | | - && apt-get -y install --no-install-recommends htop vim curl git build-essential \ |
38 | | - libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \ |
39 | | - zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \ |
40 | | - jq apt-transport-https ca-certificates gnupg-agent \ |
41 | | - software-properties-common bash-completion python3-pip make libbz2-dev \ |
42 | | - libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ |
43 | | - xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev uuid-runtime xxd unzip |
44 | | - |
45 | | -# install aws stuff |
46 | | -# Download correct AWS CLI for arch |
47 | | -RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ |
48 | | - wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \ |
49 | | - else \ |
50 | | - wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \ |
51 | | - fi && \ |
52 | | - unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \ |
53 | | - /tmp/aws-cli/aws/install && \ |
54 | | - rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli |
55 | | - |
56 | | -# Install ASDF |
57 | | -RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \ |
58 | | - if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ |
59 | | - wget -O /tmp/asdf.tar.gz "https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-arm64.tar.gz"; \ |
60 | | - else \ |
61 | | - wget -O /tmp/asdf.tar.gz "https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-amd64.tar.gz"; \ |
62 | | - fi && \ |
63 | | - tar -xzf /tmp/asdf.tar.gz -C /tmp && \ |
64 | | - mkdir -p /usr/bin && \ |
65 | | - mv /tmp/asdf /usr/bin/asdf && \ |
66 | | - chmod +x /usr/bin/asdf && \ |
67 | | - rm -rf /tmp/asdf.tar.gz |
68 | | - |
69 | | -# install gitsecrets |
70 | | -RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \ |
71 | | - cd /tmp/git-secrets && \ |
72 | | - make install && \ |
73 | | - cd && \ |
74 | | - rm -rf /tmp/git-secrets && \ |
75 | | - mkdir -p /usr/share/secrets-scanner && \ |
76 | | - chmod 755 /usr/share/secrets-scanner && \ |
77 | | - 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 |
78 | | - |
79 | | -COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy |
80 | | - |
81 | | -USER vscode |
82 | | - |
83 | | -ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin" |
84 | | -RUN \ |
85 | | - echo 'PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \ |
86 | | - echo '. <(asdf completion bash)' >> ~/.bashrc; \ |
87 | | - echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \ |
88 | | - echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \ |
89 | | - echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc; |
90 | | - |
91 | | -# Install ASDF plugins |
92 | | -RUN asdf plugin add python; \ |
93 | | - asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \ |
94 | | - asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \ |
95 | | - asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \ |
96 | | - asdf plugin add direnv; \ |
97 | | - asdf plugin add actionlint; \ |
98 | | - asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \ |
99 | | - asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git; |
100 | | - |
101 | | -WORKDIR /workspaces/eps-devcontainers |
102 | | -COPY .tool-versions /workspaces/eps-devcontainers/.tool-versions |
103 | | -COPY .tool-versions /home/vscode/.tool-versions |
104 | | - |
105 | | -# install python before poetry to ensure correct python version is used |
106 | | -RUN asdf install python; \ |
107 | | - asdf install |
108 | | - |
109 | | -RUN git-secrets --register-aws --global && \ |
110 | | - git-secrets --add-provider --global -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt |
| 1 | +ARG IMAGE_NAME=regression_tests |
| 2 | +ARG IMAGE_VERSION=latest |
| 3 | +FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION} |
| 4 | + |
| 5 | +USER root |
| 6 | +# specify DOCKER_GID to force container docker group id to match host |
| 7 | +RUN if [ -n "${DOCKER_GID}" ]; then \ |
| 8 | + if ! getent group docker; then \ |
| 9 | + groupadd -g ${DOCKER_GID} docker; \ |
| 10 | + else \ |
| 11 | + groupmod -g ${DOCKER_GID} docker; \ |
| 12 | + fi && \ |
| 13 | + usermod -aG docker vscode; \ |
| 14 | + fi |
0 commit comments