Skip to content

Commit 18a5976

Browse files
committed
chore: set up Docker image generation
1 parent e6214a0 commit 18a5976

File tree

14 files changed

+652
-410
lines changed

14 files changed

+652
-410
lines changed

.github/workflows/cd-publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
outputs:
45-
ref: ${{ github.ref }}
4645
published: ${{ steps.changesets.outputs.published }}
46+
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
4747

4848
deploy-to-registries:
4949
name: Deploy to registries
5050
uses: ./.github/workflows/cd-registries.yaml
5151
needs: publish
5252
with:
53-
ref: ${{ needs.publish.outputs.ref }}
53+
publishedPackages: ${{ needs.publish.outputs.publishedPackages }}
5454
secrets: inherit
5555
if: ${{ needs.publish.outputs.published }}

.github/workflows/cd-registries.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ name: Deploy to registries
33
on:
44
workflow_call:
55
inputs:
6-
ref:
6+
publishedPackages:
77
required: true
88
type: string
99
workflow_dispatch:
1010

1111
env:
12-
# Use docker.io for Docker Hub if empty
1312
REGISTRY: ghcr.io
14-
# github.repository as <account>/<repo>
1513
IMAGE_NAME: ${{ github.repository }}
1614

1715
jobs:
1816
build-and-deploy:
1917
name: Build and deploy
2018
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
package: ${{ fromJson(inputs.publishedPackages) }}
2122
steps:
2223
- name: Checkout repo
2324
uses: actions/checkout@v4
2425
with:
25-
ref: ${{ inputs.ref }}
26+
ref: ${{ matrix.package.name }}@${{ matrix.package.version }}
2627
fetch-depth: 0
2728

2829
- name: Set up Docker Buildx
@@ -49,9 +50,25 @@ jobs:
4950
- name: Install dependencies
5051
run: pnpm install
5152

52-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
53-
uses: nrwl/nx-set-shas@v3
54-
55-
- name: 'Build images'
56-
run: INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} pnpm nx affected --base=$NX_BASE --head=$NX_HEAD --target=container --parallel=2
53+
- name: Generate tags
54+
id: set-tags
55+
run: |
56+
VERSION=${{ matrix.package.version }}
57+
MAJOR=$(echo $VERSION | cut -d. -f1)
58+
MINOR=$(echo $VERSION | cut -d. -f2)
59+
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
60+
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
5761
62+
- name: Build and deploy images
63+
env:
64+
PACKAGE_NAME: ${{ matrix.package.name }}
65+
PACKAGE_VERSION: ${{ matrix.package.version }}
66+
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
INPUT_TAGS: "latest\n${{ github.sha }}\n${{ matrix.package.version }}\n${{steps.set-tags.outputs.MAJOR}}\n${{steps.set-tags.outputs.MAJOR}}.${{steps.set-tags.outputs.MINOR}}"
68+
run: |
69+
if pnpm nx show projects -t container | grep -q ${{ env.PACKAGE_NAME }}; then
70+
echo "Running container target for ${{ env.PACKAGE_NAME }}:${{ env.PACKAGE_VERSION }}"
71+
pnpm nx run ${{ env.PACKAGE_NAME }}:container
72+
else
73+
echo "Skipping ${{ env.PACKAGE_NAME }}:${{ env.PACKAGE_VERSION }} as it does not have a container target"
74+
fi

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ As a **developer** get started as follows:
1919
1. Open the project in the Dev Container and run `pnpm dev`
2020
1. Lint the code with `pnpm check:types`, `pnpm check:format` and `pnpm check:lint`.
2121
1. Run tests with `pnpm test`
22+
1. Further steps are outlined in the [developer guide](./docs/developer.md).
2223

2324
## Structure
2425

apps/backend/CHANGELOG.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,113 @@
11
# backend
22

3+
## 0.0.19
4+
5+
### Patch Changes
6+
7+
- ced7c16: Fix workflow
8+
9+
## 0.0.18
10+
11+
### Patch Changes
12+
13+
- 21680db: Fix versioning tags
14+
15+
## 0.0.17
16+
17+
### Patch Changes
18+
19+
- 48c7ca1: Evaluate control characters
20+
21+
## 0.0.16
22+
23+
### Patch Changes
24+
25+
- c4488cc: Fix publish workflow
26+
27+
## 0.0.15
28+
29+
### Patch Changes
30+
31+
- c2cc6f0: Enhance image tagging
32+
33+
## 0.0.14
34+
35+
### Patch Changes
36+
37+
- 417e0bf: Set semver output tags
38+
39+
## 0.0.13
40+
41+
### Patch Changes
42+
43+
- 21d46af: Add input tags
44+
45+
## 0.0.12
46+
47+
### Patch Changes
48+
49+
- 949b05b: Set fallback globally
50+
51+
## 0.0.11
52+
53+
### Patch Changes
54+
55+
- 82b36b3: Fallback to local
56+
57+
## 0.0.10
58+
59+
### Patch Changes
60+
61+
- 3e8f372: Fix image tags
62+
63+
## 0.0.9
64+
65+
### Patch Changes
66+
67+
- 74e8066: Add github token
68+
69+
## 0.0.8
70+
71+
### Patch Changes
72+
73+
- 1e64cbe: Use matrix strategy to build images
74+
75+
## 0.0.7
76+
77+
### Patch Changes
78+
79+
- 81a6e75: Export version number
80+
81+
## 0.0.6
82+
83+
### Patch Changes
84+
85+
- 71a36e0: Fix nx config
86+
87+
## 0.0.5
88+
89+
### Patch Changes
90+
91+
- f47b7bc: Fix iterate published packages
92+
93+
## 0.0.4
94+
95+
### Patch Changes
96+
97+
- 4132193: Read published packages
98+
99+
## 0.0.3
100+
101+
### Patch Changes
102+
103+
- a1bdce1: Fix container target
104+
105+
## 0.0.2
106+
107+
### Patch Changes
108+
109+
- 8113ed9: Project setup
110+
3111
## 0.0.1
4112

5113
### Patch Changes

apps/backend/package.json

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backend",
3-
"version": "0.0.1",
3+
"version": "0.0.19",
44
"description": "",
55
"author": "",
66
"private": true,
@@ -21,23 +21,23 @@
2121
"test:e2e": "jest --config ./test/jest-e2e.json"
2222
},
2323
"dependencies": {
24-
"@nestjs/common": "^10.0.0",
25-
"@nestjs/core": "^10.0.0",
26-
"@nestjs/platform-express": "^10.0.0",
24+
"@nestjs/common": "^10.4.4",
25+
"@nestjs/core": "^10.4.4",
26+
"@nestjs/platform-express": "^10.4.4",
2727
"reflect-metadata": "^0.2.0",
2828
"rxjs": "^7.8.1"
2929
},
3030
"devDependencies": {
3131
"@nestjs/cli": "^10.0.0",
3232
"@nestjs/schematics": "^10.0.0",
33-
"@nestjs/testing": "^10.0.0",
33+
"@nestjs/testing": "^10.4.4",
3434
"@types/express": "^4.17.17",
3535
"@types/jest": "^29.5.2",
36-
"@types/node": "^20.3.1",
36+
"@types/node": "^20.16.7",
3737
"@types/supertest": "^6.0.0",
38-
"@typescript-eslint/eslint-plugin": "^8.0.0",
39-
"@typescript-eslint/parser": "^8.0.0",
40-
"eslint": "^8.42.0",
38+
"@typescript-eslint/eslint-plugin": "^8.7.0",
39+
"@typescript-eslint/parser": "^8.7.0",
40+
"eslint": "^8.57.1",
4141
"eslint-config-prettier": "^9.0.0",
4242
"eslint-plugin-prettier": "^5.0.0",
4343
"jest": "^29.5.0",
@@ -66,31 +66,5 @@
6666
],
6767
"coverageDirectory": "../coverage",
6868
"testEnvironment": "node"
69-
},
70-
"nx": {
71-
"targets": {
72-
"container": {
73-
"executor": "@nx-tools/nx-container:build",
74-
"dependsOn": [
75-
"build"
76-
],
77-
"options": {
78-
"engine": "docker",
79-
"metadata": {
80-
"images": [
81-
"backend"
82-
],
83-
"load": true,
84-
"tags": [
85-
"type=schedule",
86-
"type=ref,event=branch",
87-
"type=ref,event=tag",
88-
"type=ref,event=pr",
89-
"type=sha,prefix=sha-"
90-
]
91-
}
92-
}
93-
}
94-
}
9569
}
9670
}

apps/backend/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "backend",
3+
"targets": {
4+
"container": {
5+
"executor": "@nx-tools/nx-container:build"
6+
}
7+
}
8+
}

apps/frontend/CHANGELOG.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,113 @@
11
# frontend
22

3+
## 0.0.19
4+
5+
### Patch Changes
6+
7+
- ced7c16: Fix workflow
8+
9+
## 0.0.18
10+
11+
### Patch Changes
12+
13+
- 21680db: Fix versioning tags
14+
15+
## 0.0.17
16+
17+
### Patch Changes
18+
19+
- 48c7ca1: Evaluate control characters
20+
21+
## 0.0.16
22+
23+
### Patch Changes
24+
25+
- c4488cc: Fix publish workflow
26+
27+
## 0.0.15
28+
29+
### Patch Changes
30+
31+
- c2cc6f0: Enhance image tagging
32+
33+
## 0.0.14
34+
35+
### Patch Changes
36+
37+
- 417e0bf: Set semver output tags
38+
39+
## 0.0.13
40+
41+
### Patch Changes
42+
43+
- 21d46af: Add input tags
44+
45+
## 0.0.12
46+
47+
### Patch Changes
48+
49+
- 949b05b: Set fallback globally
50+
51+
## 0.0.11
52+
53+
### Patch Changes
54+
55+
- 82b36b3: Fallback to local
56+
57+
## 0.0.10
58+
59+
### Patch Changes
60+
61+
- 3e8f372: Fix image tags
62+
63+
## 0.0.9
64+
65+
### Patch Changes
66+
67+
- 74e8066: Add github token
68+
69+
## 0.0.8
70+
71+
### Patch Changes
72+
73+
- 1e64cbe: Use matrix strategy to build images
74+
75+
## 0.0.7
76+
77+
### Patch Changes
78+
79+
- 81a6e75: Export version number
80+
81+
## 0.0.6
82+
83+
### Patch Changes
84+
85+
- 71a36e0: Fix nx config
86+
87+
## 0.0.5
88+
89+
### Patch Changes
90+
91+
- f47b7bc: Fix iterate published packages
92+
93+
## 0.0.4
94+
95+
### Patch Changes
96+
97+
- 4132193: Read published packages
98+
99+
## 0.0.3
100+
101+
### Patch Changes
102+
103+
- a1bdce1: Fix container target
104+
105+
## 0.0.2
106+
107+
### Patch Changes
108+
109+
- 8113ed9: Project setup
110+
3111
## 0.0.1
4112

5113
### Patch Changes

0 commit comments

Comments
 (0)