Repository navigation
109 lines (105 loc) · 3.27 KB
/
Copy pathdocker.yaml
File metadata and controls
109 lines (105 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Docker
on:
pull_request:
paths:
- ".github/workflows/docker.yaml"
- ".dockerignore"
- "api/package.json"
- "deployments/docker/**"
- "docs/package.json"
- "package.json"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "server/**"
- "scripts/install-hooks.mjs"
- "scripts/lib/commands.mjs"
- "web/**"
- "packages/ui/**"
push:
tags: ["v*.*.*"]
workflow_dispatch:
permissions:
contents: read
jobs:
image:
name: Build and smoke test
permissions:
contents: read
runs-on: ubuntu-latest
env:
PROJECT_TEMPLATE_IMAGE: project-template
PROJECT_TEMPLATE_VERSION: ci
PROJECT_TEMPLATE_DATABASE_PASSWORD: ci-database-password
PROJECT_TEMPLATE_SESSION_HASH_KEY: ci-session-hash-key-at-least-32-bytes
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22.23.1
cache: pnpm
- uses: docker/setup-buildx-action@v3
- name: Build local image
uses: docker/build-push-action@v6
with:
context: .
file: deployments/docker/Dockerfile
load: true
tags: project-template:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start stack
working-directory: deployments/docker
run: docker compose -f compose.yaml up -d --no-build --wait app
- name: Check health
run: curl --fail --show-error --retry 10 --retry-delay 2 http://localhost:3000/api/v1/healthz
- name: Install browser test dependencies
run: |
pnpm install --frozen-lockfile
pnpm --filter @project-template/web exec playwright install --with-deps chromium
- name: Run production-stack browser flow
env:
E2E_BASE_URL: http://127.0.0.1:3000
run: pnpm --filter @project-template/web test:e2e
- name: Show container logs
if: failure()
working-directory: deployments/docker
run: docker compose -f compose.yaml logs
- name: Stop stack
if: always()
working-directory: deployments/docker
run: docker compose -f compose.yaml down --volumes
publish:
name: Publish
if: startsWith(github.ref, 'refs/tags/v')
needs: image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-
- uses: docker/build-push-action@v6
with:
context: .
file: deployments/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max