Skip to content

Commit 1b54f96

Browse files
authored
Chore: [AEA-0000] - finish as root (#15)
## Summary - Routine Change ### Details - need to finish as root user
1 parent b7823e9 commit 1b54f96

File tree

14 files changed

+48
-51
lines changed

14 files changed

+48
-51
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ RUN asdf plugin add python; \
8282
asdf plugin add direnv; \
8383
asdf plugin add actionlint; \
8484
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \
85-
asdf plugin add trivy https://github.com/zufardhiyaulhaq/asdf-trivy.git
85+
asdf plugin add trivy https://github.com/zufardhiyaulhaq/asdf-trivy.git; \
86+
asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git
8687

8788

8889
WORKDIR /workspaces/eps-devcontainers

.github/scripts/delete_unused_images.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
2-
set -e
32

43
get_container_package_name() {
54
local container_name=$1
@@ -71,9 +70,9 @@ delete_pr_images() {
7170
if [[ -n "${version_id}" ]]; then
7271
echo "Deleting image with tag ${tag} (version ID: ${version_id}) from container ${container_name}..."
7372
gh api \
74-
-H "Accept: application/vnd.github+json" \
75-
-X DELETE \
76-
"/orgs/nhsdigital/packages/container/${package_name}/versions/${version_id}"
73+
-H "Accept: application/vnd.github+json" \
74+
-X DELETE \
75+
"/orgs/nhsdigital/packages/container/${package_name}/versions/${version_id}"
7776
fi
7877
done
7978
fi

.github/workflows/build_multi_arch_image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ jobs:
8787
BASE_VERSION: ${{ inputs.docker_tag}}
8888
IMAGE_TAG: ":${{ inputs.docker_tag }}-${{ matrix.arch }}"
8989
BASE_FOLDER: "${{ inputs.base_folder }}"
90+
VSCODE_UID: "1001"
91+
VSCODE_GID: "1001"
9092
- name: Check docker vulnerabilities - json output
9193
uses: aquasecurity/trivy-action@c1824fd6edce30d7ab345a9989de00bbd46ef284
9294
with:
Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Delete old cloudformation stacks"
1+
name: "Delete old images"
22

33
# Controls when the action will run - in this case triggered manually and on schedule
44
on:
@@ -9,38 +9,13 @@ on:
99
branches: [main]
1010

1111
jobs:
12-
delete-old-cloudformation-stacks:
12+
delete-old-pushed-images:
1313
runs-on: ubuntu-22.04
1414
permissions:
15-
id-token: write
1615
contents: read
17-
18-
steps:
19-
- name: Checkout local code
20-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
21-
with:
22-
ref: ${{ env.BRANCH_NAME }}
23-
fetch-depth: 0
24-
25-
- name: Configure AWS Credentials
26-
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
27-
with:
28-
aws-region: eu-west-2
29-
role-to-assume: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
30-
role-session-name: psu-delete-old-stacks
31-
32-
- name: delete stacks
33-
shell: bash
34-
working-directory: .github/scripts
35-
run: ./delete_stacks.sh
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
39-
delete-old-proxygen-deployments:
40-
runs-on: ubuntu-22.04
41-
permissions:
16+
packages: write
17+
attestations: write
4218
id-token: write
43-
contents: read
4419

4520
steps:
4621
- name: Checkout local code
@@ -51,5 +26,6 @@ jobs:
5126

5227
- name: delete unused images
5328
shell: bash
54-
working-directory: .github/scripts
55-
run: ./delete_unused_images.sh
29+
run: .github/scripts/delete_unused_images.sh
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ direnv 2.37.1
66
actionlint 1.7.10
77
ruby 3.3.0
88
trivy 0.69.1
9+
yq 4.52.2

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ scan-image-json: guard-CONTAINER_NAME guard-BASE_FOLDER
5757
--scanners vuln \
5858
--exit-code 1 \
5959
--format json \
60-
--output .out/scan.out.json "${CONTAINER_PREFIX}$${CONTAINER_NAME}"
60+
--output .out/scan_results_docker.json "${CONTAINER_PREFIX}$${CONTAINER_NAME}"
6161

6262
shell-image: guard-CONTAINER_NAME
6363
docker run -it \

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ asdf install and setup for these so they are available globally as vscode user
2626
- actionlint
2727
- ruby (for github pages)
2828
- trivy
29+
- yq
2930

3031
Install and setup git-secrets
3132

@@ -147,12 +148,12 @@ CONTAINER_NAME=fhir_facade_api \
147148
## Generating a .trivyignore file
148149
You can generate a .trivyignore file for known vulnerabilities by either downloading the json scan output generated by the build, or by generating it locally using the scanning images commands above with a make target of scan-image-json
149150

150-
If generated locally, then the output goes into .out/scan.out.json
151+
If generated locally, then the output goes into .out/scan_results_docker.json
151152

152153
Once you have the scan output, use the following to generate a .trivyignore
153154
```
154155
poetry run python \
155156
scripts/trivy_to_trivyignore.py \
156-
--input .out/scan.out.json \
157+
--input .out/scan_results_docker.json \
157158
--output src/common/.trivyignore.yaml
158159
```

src/base/.devcontainer/.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ direnv 2.37.1
33
actionlint 1.7.10
44
ruby 3.3.0
55
trivy 0.69.1
6+
yq 4.52.2

src/base/.devcontainer/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
22

3+
ARG BASE_VERSION=latest
34
ARG TARGETARCH
4-
ENV TARGETARCH=${TARGETARCH}
55
ARG SCRIPTS_DIR=/usr/local/share/eps
66
ARG CONTAINER_NAME
7+
ENV TARGETARCH=${TARGETARCH}
78
ENV CONTAINER_NAME=${CONTAINER_NAME}
89
ENV SCRIPTS_DIR=${SCRIPTS_DIR}
10+
ENV BASE_VERSION=${BASE_VERSION}
911

1012
LABEL org.opencontainers.image.source=https://github.com/NHSDigital/eps-devcontainers
1113
LABEL org.opencontainers.image.description="EPS base devcontainer"
1214
LABEL org.opencontainers.image.licenses=MIT
1315

14-
ARG ASDF_VERSION
1516
COPY .tool-versions.asdf ${SCRIPTS_DIR}/${CONTAINER_NAME}/.tool-versions.asdf
16-
1717
COPY --chmod=755 scripts ${SCRIPTS_DIR}/${CONTAINER_NAME}
18+
1819
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
1920
RUN ./root_install.sh
2021

2122
USER vscode
22-
23-
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
24-
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
2523
COPY --chown=vscode:vscode .tool-versions.asdf /home/vscode/.tool-versions.asdf
2624
COPY --chown=vscode:vscode .tool-versions /home/vscode/.tool-versions
2725

26+
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
27+
WORKDIR ${SCRIPTS_DIR}/${CONTAINER_NAME}
2828
RUN ./vscode_install.sh
29-
WORKDIR /home/vscode

src/base/.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"build": {
77
"dockerfile": "Dockerfile",
88
"args": {
9-
"CONTAINER_NAME": "eps_devcontainer_base"
9+
"CONTAINER_NAME": "eps_devcontainer_base",
10+
"VSCODE_UID": "${localEnv:VSCODE_UID}",
11+
"VSCODE_GID": "${localEnv:VSCODE_GID}"
1012
}
1113
},
1214
"runArgs": [

0 commit comments

Comments
 (0)