Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.git
.github
node_modules
**/node_modules
.next
**/.next
out
build
coverage
*.tsbuildinfo
.env*.local
deploy
installer
tests
*.md
78 changes: 78 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Uitrollen naar de server
description: Zet een image op de eigen server via SSH (zie deploy/README.nl.md). Slaat over met een waarschuwing als DEPLOY_HOST niet ingesteld is.

inputs:
environment:
description: qa, acc of production
required: true
image:
description: Volledige image-naam, bv. ghcr.io/dafkedd/projectx-eid@sha256:…
required: true
url:
description: Adres om na het uitrollen te controleren (vars.DEPLOY_URL)
required: false
host:
required: false
port:
required: false
user:
required: false
ssh-key:
required: false
known-hosts:
required: false
registry-token:
description: Token waarmee de server het image van ghcr.io haalt (github.token, alleen tijdens deze job geldig)
required: true

runs:
using: composite
steps:
- name: Uitrollen
shell: bash
env:
ENVIRONMENT: ${{ inputs.environment }}
IMAGE: ${{ inputs.image }}
DEPLOY_HOST: ${{ inputs.host }}
DEPLOY_PORT: ${{ inputs.port }}
DEPLOY_USER: ${{ inputs.user }}
DEPLOY_SSH_KEY: ${{ inputs.ssh-key }}
DEPLOY_KNOWN_HOSTS: ${{ inputs.known-hosts }}
REGISTRY_TOKEN: ${{ inputs.registry-token }}
run: |
if [ -z "$DEPLOY_HOST" ]; then
echo "::warning::Geen DEPLOY_HOST: $ENVIRONMENT niet uitgerold (zie deploy/README.nl.md)."
exit 0
fi
if [ -z "$DEPLOY_SSH_KEY" ] || [ -z "$DEPLOY_KNOWN_HOSTS" ]; then
echo "::error::DEPLOY_SSH_KEY en DEPLOY_KNOWN_HOSTS zijn nodig om naar $DEPLOY_HOST uit te rollen."
exit 1
fi
dir="$RUNNER_TEMP/ssh"
install -d -m 700 "$dir"
printf '%s\n' "$DEPLOY_SSH_KEY" > "$dir/key"
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$dir/known_hosts"
chmod 600 "$dir/key" "$dir/known_hosts"
# De server staat voor deze sleutel alleen "deploy <omgeving> <image>" toe; het token gaat via stdin.
printf '%s' "$REGISTRY_TOKEN" | ssh -i "$dir/key" -p "${DEPLOY_PORT:-22}" \
-o UserKnownHostsFile="$dir/known_hosts" -o StrictHostKeyChecking=yes -o BatchMode=yes \
-o ConnectTimeout=20 -o ServerAliveInterval=15 \
"${DEPLOY_USER:-deploy}@$DEPLOY_HOST" "deploy $ENVIRONMENT $IMAGE"
rm -rf "$dir"

- name: Controleren
if: inputs.url != '' && inputs.host != ''
shell: bash
env:
URL: ${{ inputs.url }}
run: |
for i in $(seq 1 20); do
if curl -fsS -o /dev/null --max-time 10 "$URL"; then
echo "OK: $URL"
echo "### ${{ inputs.environment }}: $URL" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
sleep 6
done
echo "::error::$URL antwoordt niet na het uitrollen."
exit 1
24 changes: 21 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,33 @@ jobs:
public/downloads/projectx-eid-setup.exe.sha256
if-no-files-found: error

# Het Docker-image voor QA, ACC en productie moet blijven bouwen (zie Dockerfile en deploy/).
docker:
name: docker image
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- run: docker build -t projectx-eid:ci .
- name: Container starten en controleren
run: |
docker run -d --name projectx-ci -p 3000:3000 projectx-eid:ci
for i in $(seq 1 30); do
if curl -fsS -o /dev/null http://127.0.0.1:3000/; then echo "OK"; exit 0; fi
sleep 2
done
docker logs projectx-ci
exit 1

# Eén vaste naam om als vereiste check voor main in te stellen.
ci-check:
name: CI-check
if: always()
needs: [check, setup]
needs: [check, setup, docker]
runs-on: ubuntu-latest
steps:
- run: |
echo "check: ${{ needs.check.result }}, setup: ${{ needs.setup.result }}"
if [ "${{ needs.check.result }}" != "success" ] || [ "${{ needs.setup.result }}" != "success" ]; then
echo "check: ${{ needs.check.result }}, setup: ${{ needs.setup.result }}, docker: ${{ needs.docker.result }}"
if [ "${{ needs.check.result }}" != "success" ] || [ "${{ needs.setup.result }}" != "success" ] || [ "${{ needs.docker.result }}" != "success" ]; then
exit 1
fi
123 changes: 98 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: Release

# Alleen op de branch `release` (meestal een merge main → release). Stappen, zoals in Azure DevOps:
# 1. ci alle tests (ci.yml)
# 2. qa uitrollen naar QA (environment "qa")
# 3. acc uitrollen naar acceptatie (environment "acc")
# 4. release tag v<versie> + GitHub-release met de Windows-setup (environment "production"),
# en @dafkedd/eid naar npmjs.com en GitHub Packages als die versie daar nog niet staat
# 2. image Docker-image bouwen (met de Windows-setup erin) en naar ghcr.io zetten
# 3. qa dat image uitrollen naar QA (environment "qa")
# 4. acc hetzelfde image naar acceptatie (environment "acc")
# 5. release hetzelfde image naar productie, tag v<versie> + GitHub-release met de Windows-setup
# (environment "production"), en @dafkedd/eid naar npmjs.com en GitHub Packages als
# die versie daar nog niet staat
# Uitrollen gaat via SSH naar de eigen server (deploy/README.nl.md). Zonder secret DEPLOY_HOST wordt er
# niet uitgerold, alleen gewaarschuwd.
# Met "Required reviewers" op een environment wacht die stap op een knop "Approve" in het tabblad Actions.
# Bestaat tag v<versie> al, dan wordt er geen release gemaakt: verhoog eerst de versie (npm run version:patch).

Expand All @@ -24,51 +28,120 @@ jobs:
ci:
uses: ./.github/workflows/ci.yml

image:
name: Image
needs: ci
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.push.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Windows-setup ophalen (uit de CI-stap), voor de downloadknop in de app
uses: actions/download-artifact@v4
with:
name: windows-setup
path: public/downloads
- name: Bouwen en naar ghcr.io
id: push
env:
GH_TOKEN: ${{ github.token }}
run: |
repo="ghcr.io/${GITHUB_REPOSITORY,,}"
version=$(node -p "require('./package.json').version")
tag="$repo:$version-${GITHUB_SHA::7}"
echo "$GH_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
docker build \
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
--label "org.opencontainers.image.revision=$GITHUB_SHA" \
--label "org.opencontainers.image.version=$version" \
-t "$tag" -t "$repo:sha-$GITHUB_SHA" .
docker push "$tag"
docker push "$repo:sha-$GITHUB_SHA"
digest=$(docker inspect --format '{{index .RepoDigests 0}}' "$tag")
echo "image=$digest" >> "$GITHUB_OUTPUT"
echo "### Image: \`$tag\`" >> "$GITHUB_STEP_SUMMARY"

qa:
name: QA
needs: ci
needs: image
runs-on: ubuntu-latest
environment: qa
timeout-minutes: 15
environment:
name: qa
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: ./.github/actions/deploy
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
# TODO: hier uitrollen naar de QA-omgeving (bv. Azure Web App, Vercel of een eigen server).
- run: echo "QA-build klaar voor ${GITHUB_SHA::7}. Uitrollen naar QA is nog niet ingesteld."
environment: qa
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}

acc:
name: ACC
needs: qa
needs: [image, qa]
runs-on: ubuntu-latest
environment: acc
timeout-minutes: 15
environment:
name: acc
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: ./.github/actions/deploy
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
# TODO: hier uitrollen naar de acceptatie-omgeving.
- run: echo "ACC-build klaar voor ${GITHUB_SHA::7}. Uitrollen naar ACC is nog niet ingesteld."
environment: acc
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}

release:
name: Release
needs: acc
needs: [image, acc]
runs-on: ubuntu-latest
environment: production
environment:
name: production
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: write
packages: write
packages: write # GitHub Packages publiceren (en het image lezen)
id-token: write # npm provenance
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Uitrollen naar productie
uses: ./.github/actions/deploy
with:
environment: production
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}
- uses: actions/setup-node@v4
with:
node-version: 22
Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
# ProjectX als container, voor QA, ACC en productie op de eigen server (zie deploy/README.nl.md).
# De release-pipeline bouwt dit image één keer en zet het achtereenvolgens op QA, ACC en productie.

ARG NODE_VERSION=22

FROM node:${NODE_VERSION}-bookworm-slim AS build
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY . .
RUN npm ci --no-audit --no-fund && npm run build

FROM node:${NODE_VERSION}-bookworm-slim AS run
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
HOSTNAME=0.0.0.0 \
PORT=3000
COPY --from=build --chown=node:node /app/.next/standalone ./
COPY --from=build --chown=node:node /app/.next/static ./.next/static
COPY --from=build --chown=node:node /app/public ./public
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["node", "-e", "fetch('http://127.0.0.1:3000/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
CMD ["node", "server.js"]
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ End users need the eID program. One command builds a setup with ProjectX's websi
double-clicking is enough, no admin rights needed, and the program then starts automatically when
the user signs in to Windows.

1. Put ProjectX's production address in `installer/eid-installer.json` (`origins`, and
1. ProjectX's websites (local, QA, ACC, production) are in `installer/eid-installer.json` (`origins`, and
`authOrigins` if you use PIN login).
2. Once: `winget install JRSoftware.InnoSetup`.
3. Build (on Windows, Node 22 or 24):
Expand Down Expand Up @@ -123,10 +123,14 @@ like in Azure DevOps:

| Step | Environment | What |
| --- | --- | --- |
| CI | — | Typecheck, tests and build on Linux and Windows; build and test the Windows setup |
| QA | `qa` | Build for QA (deployment still to be filled in) |
| ACC | `acc` | Build for acceptance (deployment still to be filled in) |
| Release | `production` | Tag `v<version>` + GitHub release with the Windows setup, zip and sha256 |
| CI | — | Typecheck, tests and build on Linux and Windows; build and test the Windows setup; build the Docker image |
| Image | — | Docker image (with the Windows setup inside) to `ghcr.io` |
| QA | `qa` | Deploy that image to https://qa.dafkedd.be |
| ACC | `acc` | Deploy the same image to https://acc.dafkedd.be |
| Release | `production` | Same image to https://prod.dafkedd.be, then tag `v<version>` + GitHub release with the Windows setup, zip and sha256 |

Deployment goes over SSH to our own Debian server with Docker and Caddy. Setup and secrets:
[deploy/README.md](deploy/README.md).

Making a release:

Expand Down
14 changes: 9 additions & 5 deletions README.nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Eindgebruikers hebben het eID-programma nodig. Met één commando bouw je een se
van ProjectX al ingebakken zitten: dubbelklikken volstaat, zonder beheerdersrechten, en het programma
start daarna automatisch bij het aanmelden in Windows.

1. Zet het adres van ProjectX in productie in `installer/eid-installer.json` (`origins`, en
1. De websites van ProjectX (lokaal, QA, ACC, productie) staan in `installer/eid-installer.json` (`origins`, en
`authOrigins` als je aanmelden met PIN gebruikt).
2. Eenmalig: `winget install JRSoftware.InnoSetup`.
3. Bouwen (op Windows, Node 22 of 24):
Expand Down Expand Up @@ -124,10 +124,14 @@ draaien alleen de tests (`ci.yml`). Alleen een push naar `release` start de rele

| Stap | Environment | Wat |
| --- | --- | --- |
| CI | — | Typecheck, tests en build op Linux en Windows; Windows-setup bouwen en testen |
| QA | `qa` | Build voor QA (uitrollen nog in te vullen) |
| ACC | `acc` | Build voor acceptatie (uitrollen nog in te vullen) |
| Release | `production` | Tag `v<versie>` + GitHub-release met de Windows-setup, zip en sha256 |
| CI | — | Typecheck, tests en build op Linux en Windows; Windows-setup bouwen en testen; Docker-image bouwen |
| Image | — | Docker-image (met de Windows-setup erin) naar `ghcr.io` |
| QA | `qa` | Dat image uitrollen naar https://qa.dafkedd.be |
| ACC | `acc` | Hetzelfde image naar https://acc.dafkedd.be |
| Release | `production` | Hetzelfde image naar https://prod.dafkedd.be, dan tag `v<versie>` + GitHub-release met de Windows-setup, zip en sha256 |

Uitrollen gaat via SSH naar onze eigen Debian-server met Docker en Caddy. Instellen en secrets:
[deploy/README.nl.md](deploy/README.nl.md).

Een release maken:

Expand Down
Loading
Loading