@@ -31,8 +31,8 @@ asdf install and setup for these so they are available globally as vscode user
3131Install and setup git-secrets
3232
3333# Using the images
34- In each eps project, this should be the contents of .devcontainer/Dockerfile.
35-
34+ ## Project setup
35+ In each eps project, ` .devcontainer/Dockerfile ` should be set to
3636```
3737ARG IMAGE_NAME=node_24_python_3_14
3838ARG IMAGE_VERSION=latest
@@ -49,11 +49,7 @@ RUN if [ -n "${DOCKER_GID}" ]; then \
4949 usermod -aG docker vscode; \
5050 fi
5151```
52- And this should be the contents of .devcontainer/devcontainer.json.
53- This file will be used in github workflows to calculate the version of container to use in builds, so it must be valid JSON (no comments).
54- The name should be changed to match the name of the project.
55- IMAGE_NAME and IMAGE_VERSION should be changed as appropriate.
56- You should not need to add any features as these are already baked into the image
52+ ` .devcontainer/devcontainer.json ` should be set to.
5753```
5854{
5955 "name": "eps-common-workflows",
@@ -86,7 +82,12 @@ You should not need to add any features as these are already baked into the imag
8682 }
8783}
8884```
85+ Note - this file will be used in github workflows to calculate the version of container to use in builds, so it must be valid JSON (no comments).
86+ The name should be changed to match the name of the project.
87+ IMAGE_NAME and IMAGE_VERSION should be changed as appropriate.
88+ You should not need to add any features as these are already baked into the image
8989
90+ ## Getting image name and version in github actions
9091This job should be used in github actions wherever you need to get the dev container name or tag
9192
9293```
@@ -106,6 +107,30 @@ This job should be used in github actions wherever you need to get the dev conta
106107 echo "DEVCONTAINER_IMAGE_NAME=$DEVCONTAINER_IMAGE_NAME" >> "$GITHUB_OUTPUT"
107108 echo "DEVCONTAINER_IMAGE_VERSION=$DEVCONTAINER_VERSION" >> "$GITHUB_OUTPUT"
108109```
110+ ## Using images in github actions
111+ To use the image in github actions, you can use code like this
112+ ```
113+ jobs:
114+ my_job_name:
115+ runs-on: ubuntu-22.04
116+ container:
117+ image: ghcr.io/nhsdigital/eps-devcontainers/<container name>:githubactions-<tag>
118+ options: --user 1001:1001 --group-add 128
119+ defaults:
120+ run:
121+ shell: bash
122+ steps:
123+ - name: copy .tool-versions
124+ run: |
125+ cp /home/vscode/.tool-versions "$HOME/.tool-versions"
126+ ... other steps ....
127+ ```
128+ It is important that
129+ - the image specified uses the tag starting githubactions-
130+ - there is ` options: --user 1001:1001 --group-add 128 ` below image to ensure it uses the correct user id and is added to the docker group
131+ - the default shell is set to be bash
132+ - the first step copies .tool-versions from /home/vscode to $HOME/.tool-versions
133+
109134# Project structure
110135We have 4 types of dev container. These are defined under src
111136
@@ -235,26 +260,6 @@ For an image built locally, you should put the IMAGE_VERSION=local-build.
235260For an image built from a pull request, you should put the IMAGE_VERSION=<tag of image as show in pull request job >.
236261You can only use images built from a pull request for testing changes in github actions.
237262
238- ## Using images in github actions
239- To use the image in github actions, you can use it in github actions using code like this
240- ```
241- jobs:
242- my_job_name:
243- runs-on: ubuntu-22.04
244- container:
245- image: ghcr.io/nhsdigital/eps-devcontainers/<container name>:githubactions-<tag>
246- options: --user 1001:1001
247- steps:
248- - name: copy .tool-versions
249- run: |
250- cp /home/vscode/.tool-versions "$HOME/.tool-versions"
251- ... other steps ....
252- ```
253- It is important that
254- - the image uses the tag starting githubactions-
255- - there is ` options: --user 1001:1001 ` below image
256- - the first step copies .tool-versions from /home/vscode to $HOME/.tool-versions
257-
258263## Generating a .trivyignore file
259264You 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
260265
0 commit comments