Skip to content

Commit e0808a3

Browse files
authored
Chore: [AEA-0000] - add no cache (#17)
## Summary - Routine Change ### Details - add no-cache
1 parent 2cdcba2 commit e0808a3

File tree

14 files changed

+89
-45
lines changed

14 files changed

+89
-45
lines changed

.github/workflows/build_all_images.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ name: build_all_images
88
tag_latest:
99
required: true
1010
type: boolean
11+
NO_CACHE:
12+
required: true
13+
type: boolean
1114
env:
1215
BRANCH_NAME: '${{ github.event.pull_request.head.ref }}'
1316
jobs:
@@ -32,6 +35,7 @@ jobs:
3235
docker_tag: ${{ inputs.docker_tag }}
3336
container_name: base
3437
base_folder: "."
38+
NO_CACHE: ${{ inputs.NO_CACHE }}
3539
package_language_docker_images:
3640
needs:
3741
- package_base_docker_image
@@ -46,6 +50,7 @@ jobs:
4650
docker_tag: ${{ inputs.docker_tag }}
4751
container_name: ${{ matrix.container_name }}
4852
base_folder: "languages"
53+
NO_CACHE: ${{ inputs.NO_CACHE }}
4954
package_project_docker_images:
5055
needs:
5156
- package_language_docker_images
@@ -61,3 +66,4 @@ jobs:
6166
docker_tag: ${{ inputs.docker_tag }}
6267
container_name: ${{ matrix.container_name }}
6368
base_folder: "projects"
69+
NO_CACHE: ${{ inputs.NO_CACHE }}

.github/workflows/build_multi_arch_image.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ name: Build and push docker image
1414
base_folder:
1515
required: true
1616
type: string
17+
NO_CACHE:
18+
required: true
19+
type: boolean
1720

1821
jobs:
1922
build_and_push_image:
@@ -87,6 +90,7 @@ jobs:
8790
BASE_VERSION_TAG: ${{ inputs.docker_tag}}
8891
IMAGE_TAG: "${{ inputs.docker_tag }}-${{ matrix.arch }}"
8992
BASE_FOLDER: "${{ inputs.base_folder }}"
93+
NO_CACHE: '${{ inputs.NO_CACHE }}'
9094
- name: Check docker vulnerabilities - json output
9195
uses: aquasecurity/trivy-action@c1824fd6edce30d7ab345a9989de00bbd46ef284
9296
with:

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ jobs:
4545
with:
4646
docker_tag: '${{ needs.tag_release.outputs.version_tag }}'
4747
tag_latest: false
48+
NO_CACHE: false

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ jobs:
9292
with:
9393
docker_tag: 'pr-${{ needs.get_issue_number.outputs.issue_number }}-${{ needs.get_commit_id.outputs.sha_short }}'
9494
tag_latest: false
95+
NO_CACHE: false

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ jobs:
4646
with:
4747
docker_tag: '${{ needs.tag_release.outputs.version_tag }}'
4848
tag_latest: true
49+
NO_CACHE: true

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ ifneq ($(strip $(PLATFORM)),)
44
PLATFORM_FLAG=--platform $(PLATFORM)
55
endif
66

7+
ifeq ($(strip $(NO_CACHE)),true)
8+
NO_CACHE_FLAG=--no-cache
9+
endif
10+
711
guard-%:
812
@ if [ "${${*}}" = "" ]; then \
913
echo "Environment variable $* not set"; \
@@ -24,6 +28,7 @@ install-hooks: install-python
2428
build-image: guard-CONTAINER_NAME guard-BASE_VERSION_TAG guard-BASE_FOLDER guard-IMAGE_TAG
2529
npx devcontainer build \
2630
--workspace-folder ./src/$${BASE_FOLDER}/$${CONTAINER_NAME} \
31+
$(NO_CACHE_FLAG) \
2732
--push false \
2833
--cache-from "${CONTAINER_PREFIX}$${CONTAINER_NAME}:latest" \
2934
--image-name "${CONTAINER_PREFIX}$${CONTAINER_NAME}:$${IMAGE_TAG}"

README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,30 @@ You should not need to add any features as these are already baked into the imag
6161
"name": "eps-common-workflows",
6262
"build": {
6363
"dockerfile": "Dockerfile",
64+
"context": "..",
6465
"args": {
6566
"DOCKER_GID": "${env:DOCKER_GID:}",
6667
"IMAGE_NAME": "node_24_python_3_14",
67-
"IMAGE_VERSION": "v1.0.1",
68+
"IMAGE_VERSION": "local-build",
6869
"USER_UID": "${localEnv:USER_ID:}",
6970
"USER_GID": "${localEnv:GROUP_ID:}"
7071
},
7172
"updateRemoteUserUID": false,
72-
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt",
73-
"mounts": [
74-
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
75-
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
76-
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind",
77-
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind"
78-
],
79-
"containerUser": "vscode",
80-
"remoteEnv": {
81-
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
82-
},
83-
"features": {},
84-
"customizations": {
85-
... add any customisations you want here
86-
}
73+
},
74+
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt",
75+
"mounts": [
76+
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
77+
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
78+
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind",
79+
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind"
80+
],
81+
"containerUser": "vscode",
82+
"remoteEnv": {
83+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
84+
},
85+
"features": {},
86+
"customizations": {
87+
....
8788
}
8889
}
8990
```
@@ -153,7 +154,7 @@ CONTAINER_NAME=base \
153154
```
154155
Language images
155156
```
156-
CONTAINER_NAME=node_24_python_3_12 \
157+
CONTAINER_NAME=node_24_python_3_13 \
157158
BASE_VERSION_TAG=local-build \
158159
BASE_FOLDER=languages \
159160
IMAGE_TAG=local-build \
@@ -214,17 +215,26 @@ CONTAINER_NAME=fhir_facade_api \
214215
```
215216

216217
## Using local or pull request images
217-
You can use local or pull request images by changing IMAGE_VERSION in devcontainer.json
218+
You can use local or pull request images by changing IMAGE_VERSION in devcontainer.json.
219+
For an image built locally, you should put the IMAGE_VERSION=local-build.
220+
For an image built from a pull request, you should put the IMAGE_VERSION=<tag of image as show in pull request job>.
221+
You can only use images built from a pull request for testing changes in github actions.
218222

219223
## Generating a .trivyignore file
220224
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
221225

222-
If generated locally, then the output goes into .out/scan_results_docker.json
226+
If generated locally, then the output goes into .out/scan_results_docker.json.
227+
You can use github cli tools to download the scan output file. Replace the run id from the url, and the -n with the filename to download
228+
```
229+
gh run download <run id> -n scan_results_docker_fhir_facade_api_arm64.json
230+
```
231+
232+
Once you have the scan output, use the following to generate a new .trivyignore file called .trivyignore.new.yaml. Note this will overwrite the output file when run so it should point to a new file and the contents merged with existing .trivyignore file
233+
223234

224-
Once you have the scan output, use the following to generate a .trivyignore
225235
```
226236
poetry run python \
227237
scripts/trivy_to_trivyignore.py \
228238
--input .out/scan_results_docker.json \
229-
--output src/common/.trivyignore.yaml
239+
--output src/projects/fhir_facade_api/.trivyignore.new.yaml
230240
```

src/base/.devcontainer/devcontainer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
"IMAGE_TAG": "${localEnv:IMAGE_TAG}"
1313
}
1414
},
15-
"runArgs": [
16-
"--network=host"
17-
],
18-
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
1915
"features": {
2016
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
2117
"version": "latest",

src/languages/node_24_python_3_12/.devcontainer/devcontainer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
},
1414
"context": "."
1515
},
16-
"runArgs": [
17-
"--network=host"
18-
],
19-
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
2016
"features": {}
2117
}
2218

src/languages/node_24_python_3_13/.devcontainer/devcontainer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
},
1414
"context": "."
1515
},
16-
"runArgs": [
17-
"--network=host"
18-
],
19-
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
2016
"features": {}
2117
}
2218

0 commit comments

Comments
 (0)