Skip to content

Commit aba7255

Browse files
separate containers.
1 parent e06900e commit aba7255

File tree

22 files changed

+365
-244
lines changed

22 files changed

+365
-244
lines changed

.github/workflows/cicd.yaml

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,41 @@ on:
66
push:
77
branches: ['main']
88

9-
defaults:
10-
run:
11-
working-directory: ./src/base/src/.devcontainer
129

1310

14-
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
11+
env:
12+
# Sets the Docker image tag to use for the image built in this workflow.
13+
base_dir: src/devcontainers
14+
context: .devcontainer
15+
workspace_folder: ./src
16+
readme: README.md
17+
registry: ghcr.io
18+
dockerfile: Dockerfile
19+
server: https://github.com
20+
org: NHSDigital
21+
repository: nhs-notify-devcontainers
22+
vendor: NHS England
23+
24+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
1525
jobs:
1626
build-and-push-image:
1727
runs-on: ubuntu-latest
1828
strategy:
1929
fail-fast: false
30+
max-parallel: 1
2031
matrix:
2132
include:
22-
- server: https://github.com
23-
org: NHSDigital
24-
repository: nhs-notify-devcontainers
25-
path: src/devcontainers/base
26-
readme: README.md
27-
makefile_dir: ./src/devcontainers/base
28-
context: ./src/devcontainers/base/src/.devcontainer
29-
dockerfile: Dockerfile
30-
registry: ghcr.io
33+
- container_name: base
3134
image: nhsdigital/nhs-notify-devcontainer-base
35+
version: latest
3236
title: NHS Notifiy Devcontainer Base Image
3337
description: Base development container for NHS Notify projects
34-
vendor: NHS England
35-
subFolder: ./src/devcontainers/base/src
36-
runCmd: echo "Devcontainer built successfully"
38+
- container_name: loaded
39+
image: nhsdigital/nhs-notify-devcontainer-loaded
40+
version: latest
41+
title: NHS Notifiy Devcontainer Loaded Image
42+
description: Loaded development container for NHS Notify projects
43+
3744

3845
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
3946
permissions:
@@ -49,61 +56,56 @@ jobs:
4956
- name: Log in to the Container registry
5057
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
5158
with:
52-
registry: ${{ matrix.registry }}
59+
registry: ${{ env.registry }}
5360
username: ${{ github.actor }}
5461
password: ${{ secrets.GITHUB_TOKEN }}
5562

56-
- name: Pre-build dev container image
57-
uses: devcontainers/[email protected]
63+
- uses: actions/setup-node@v6
5864
with:
59-
imageName: ${{ matrix.registry }}/${{ matrix.image }}
60-
push: always
61-
subFolder: ${{ matrix.subFolder }}
62-
runCmd: ${{ matrix.runCmd }}
65+
node-version: 24
66+
67+
- name: Build
68+
working-directory: ${{env.base_dir}}/${{ matrix.container_name }}
69+
run: |
70+
make build IMAGE_NAME=${{ env.registry }}/${{ matrix.image }} VERSION=${{ matrix.version }} WORKSPACE_FOLDER=${{ env.workspace_folder }}
6371
64-
# - uses: actions/setup-node@v6
65-
# with:
66-
# node-version: 24
6772
68-
# # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
69-
# - name: Extract metadata (tags, labels) for Docker
70-
# id: meta
71-
# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
72-
# with:
73-
# images: ${{ matrix.registry }}/${{ matrix.image }}
74-
# flavor: |
75-
# latest=auto
76-
# tags: |
77-
# type=raw,value=latest,enable={{is_default_branch}}
78-
# labels: |
79-
# org.opencontainers.image.title= ${{ matrix.title }}
80-
# org.opencontainers.image.description=${{ matrix.description }}
81-
# org.opencontainers.image.vendor=${{ matrix.vendor }}
82-
# org.opencontainers.image.url=${{ matrix.server }}/${{ matrix.org }}/${{ matrix.repository }}/blob/main/${{ matrix.path }}/${{ matrix.readme }}
83-
# org.opencontainers.image.source=${{ matrix.server }}/${{ matrix.org }}/${{ matrix.repository }}/tree/main/${{ matrix.path }}
84-
# # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
85-
# # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
86-
# # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
73+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
74+
- name: Extract metadata (tags, labels) for Docker
75+
id: meta
76+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
77+
with:
78+
images: ${{ env.registry }}/${{ matrix.image }}
79+
flavor: |
80+
latest=auto
81+
tags: |
82+
type=raw,value=latest,enable={{is_default_branch}}
83+
labels: |
84+
org.opencontainers.image.title= ${{ matrix.title }}
85+
org.opencontainers.image.description=${{ matrix.description }}
86+
org.opencontainers.image.vendor=${{ env.vendor }}
87+
org.opencontainers.image.url=${{ env.server }}/${{ env.org }}/${{ env.repository }}/blob/main/${{ env.base_dir }}/${{matrix.container_name}}/${{ env.readme }}
88+
org.opencontainers.image.source=${{ env.server }}/${{ env.org }}/${{ env.repository }}/tree/main/${{ env.base_dir }}/${{matrix.container_name}}/
8789
90+
# So we don't rebuild the container image, we create a simple Dockerfile that uses the previously built image as its source.
91+
- run: echo 'FROM ${{ env.registry }}/${{ matrix.image }}' > /tmp/Dockerfile.source
8892

89-
# - run: make build
90-
# working-directory: ${{ matrix.makefile_dir }}
9193

92-
# - name: Build and push Docker image
93-
# id: push
94-
# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
95-
# with:
96-
# context: ${{ matrix.context }}
97-
# file: ${{ matrix.context }}/${{ matrix.dockerfile }}
98-
# push: true
99-
# tags: ${{ steps.meta.outputs.tags }}
100-
# labels: ${{ steps.meta.outputs.labels }}
94+
- name: Build and push Docker image
95+
id: push
96+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
97+
with:
98+
context: .
99+
file: /tmp/Dockerfile.source
100+
push: true
101+
tags: ${{ steps.meta.outputs.tags }}
102+
labels: ${{ steps.meta.outputs.labels }}
101103

102-
# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
103-
# - name: Generate artifact attestation
104-
# uses: actions/attest-build-provenance@v3
105-
# with:
106-
# subject-name: ${{ matrix.registry }}/${{ matrix.image }}
107-
# subject-digest: ${{ steps.push.outputs.digest }}
108-
# push-to-registry: true
104+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
105+
- name: Generate artifact attestation
106+
uses: actions/attest-build-provenance@v3
107+
with:
108+
subject-name: ${{ env.registry }}/${{ matrix.image }}
109+
subject-digest: ${{ steps.push.outputs.digest }}
110+
push-to-registry: true
109111

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
push:
7+
branches: ['main']
8+
9+
defaults:
10+
run:
11+
working-directory: ./src/base/src/.devcontainer
12+
13+
14+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- server: https://github.com
23+
org: NHSDigital
24+
repository: nhs-notify-devcontainers
25+
path: src/devcontainers/base
26+
readme: README.md
27+
makefile_dir: ./src/devcontainers/base
28+
context: ./src/devcontainers/base/src/.devcontainer
29+
dockerfile: Dockerfile
30+
registry: ghcr.io
31+
image: nhsdigital/nhs-notify-devcontainer-base
32+
title: NHS Notifiy Devcontainer Base Image
33+
description: Base development container for NHS Notify projects
34+
vendor: NHS England
35+
subFolder: ./src/devcontainers/base/src
36+
runCmd: echo "Devcontainer built successfully"
37+
38+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
39+
permissions:
40+
contents: read
41+
packages: write
42+
attestations: write
43+
id-token: write
44+
#
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v5
48+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
49+
- name: Log in to the Container registry
50+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
51+
with:
52+
registry: ${{ matrix.registry }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Pre-build dev container image
57+
uses: devcontainers/[email protected]
58+
with:
59+
imageName: ${{ matrix.registry }}/${{ matrix.image }}
60+
push: always
61+
subFolder: ${{ matrix.subFolder }}
62+
runCmd: ${{ matrix.runCmd }}
63+
64+
# - uses: actions/setup-node@v6
65+
# with:
66+
# node-version: 24
67+
68+
# # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
69+
# - name: Extract metadata (tags, labels) for Docker
70+
# id: meta
71+
# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
72+
# with:
73+
# images: ${{ matrix.registry }}/${{ matrix.image }}
74+
# flavor: |
75+
# latest=auto
76+
# tags: |
77+
# type=raw,value=latest,enable={{is_default_branch}}
78+
# labels: |
79+
# org.opencontainers.image.title= ${{ matrix.title }}
80+
# org.opencontainers.image.description=${{ matrix.description }}
81+
# org.opencontainers.image.vendor=${{ matrix.vendor }}
82+
# org.opencontainers.image.url=${{ matrix.server }}/${{ matrix.org }}/${{ matrix.repository }}/blob/main/${{ matrix.path }}/${{ matrix.readme }}
83+
# org.opencontainers.image.source=${{ matrix.server }}/${{ matrix.org }}/${{ matrix.repository }}/tree/main/${{ matrix.path }}
84+
# # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
85+
# # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
86+
# # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
87+
88+
89+
# - run: make build
90+
# working-directory: ${{ matrix.makefile_dir }}
91+
92+
# - name: Build and push Docker image
93+
# id: push
94+
# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
95+
# with:
96+
# context: ${{ matrix.context }}
97+
# file: ${{ matrix.context }}/${{ matrix.dockerfile }}
98+
# push: true
99+
# tags: ${{ steps.meta.outputs.tags }}
100+
# labels: ${{ steps.meta.outputs.labels }}
101+
102+
# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
103+
# - name: Generate artifact attestation
104+
# uses: actions/attest-build-provenance@v3
105+
# with:
106+
# subject-name: ${{ matrix.registry }}/${{ matrix.image }}
107+
# subject-digest: ${{ steps.push.outputs.digest }}
108+
# push-to-registry: true
109+

src/devcontainers/base/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
IMAGE_NAME = ghcr.io/nhsdigital/nhs-notify-devcontainer-base
2+
VERSION = latest
3+
WORKSPACE_FOLDER = ./src
4+
15
build:
2-
npm install && \
3-
export PATH="./node_modules/.bin:$$PATH" && \
6+
npm install -g @devcontainers/cli && \
47
BUILDKIT_PROGRESS=plain \
58
devcontainer build \
6-
--workspace-folder ./src \
7-
--image-name "ghcr.io/nhsdigital/nhs-notify-devcontainer-base:latest"
9+
--workspace-folder $(WORKSPACE_FOLDER) \
10+
--image-name "$(IMAGE_NAME):$(VERSION)"

src/devcontainers/base/package-lock.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/devcontainers/base/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/devcontainers/base/src/.devcontainer/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ LABEL org.opencontainers.image.vendor="NHS England"
66
LABEL org.opencontainers.image.licenses=MIT
77
LABEL org.opencontainers.image.title="NHS Digital Notify Base Dev Container"
88
LABEL org.opencontainers.image.description="Base Dev Container for NHS Digital Notify development environments"
9-
WORKDIR /setup
10-
COPY scripts ./scripts
11-
WORKDIR /setup/scripts
12-
RUN . ./configure-apt.sh

0 commit comments

Comments
 (0)