Skip to content

Commit 2fb17c7

Browse files
authored
feat: deployment ready (#1)
1 parent 84248bc commit 2fb17c7

28 files changed

+1526
-1025
lines changed

.dockerignore

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Dependencies
2+
node_modules
3+
.pnpm-store
4+
5+
# Build outputs (will be built in container)
6+
dist
7+
build
8+
*.tsbuildinfo
9+
10+
# Development files
11+
.env
12+
.env.local
13+
.env.development
14+
.env.test
15+
16+
# Testing
17+
coverage
18+
.vitest
19+
20+
# Git
21+
.git
22+
.gitignore
23+
.gitattributes
24+
25+
# IDE
26+
.vscode
27+
.idea
28+
*.swp
29+
*.swo
30+
.DS_Store
31+
Thumbs.db
32+
33+
# Logs
34+
logs
35+
*.log
36+
npm-debug.log*
37+
yarn-debug.log*
38+
yarn-error.log*
39+
pnpm-debug.log*
40+
lerna-debug.log*
41+
42+
# Turbo
43+
.turbo
44+
45+
# Documentation (not needed in runtime)
46+
docs
47+
README.md
48+
LICENSE
49+
50+
# CI/CD
51+
.github
52+
53+
# Serena
54+
.serena
55+
56+
# Claude
57+
.claude
58+
59+
# Specify
60+
.specify
61+
62+
# Development scripts (not needed in production runtime)
63+
64+
# Docker files (already in image context)
65+
Dockerfile
66+
docker-compose.yml
67+
.dockerignore

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Server Configuration
2+
PORT=4000
3+
4+
# Data Path (relative to server package)
5+
# Default points to repository root data folder
6+
DATA_PATH=../../data/structure
7+
8+
# CORS Configuration
9+
# In production, set to your frontend domain(s)
10+
# Example: https://www.freecodecamp.org
11+
# Multiple origins: https://app1.example.com,https://app2.example.com
12+
CORS_ORIGIN=*
13+
14+
# Environment
15+
# Set to 'production' in production environments
16+
# CORS_ORIGIN must be explicitly set when NODE_ENV=production
17+
NODE_ENV=development

.github/workflows/docker-docr.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CD - Docker - DOCR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
site_tld:
7+
required: true
8+
type: choice
9+
description: 'Input: The site tld (variant) to build'
10+
options:
11+
- dev
12+
- org
13+
default: 'dev'
14+
workflow_call:
15+
inputs:
16+
site_tld:
17+
required: true
18+
type: string
19+
description: 'Input: The site tld (variant) to build'
20+
outputs:
21+
tagname:
22+
description: 'Output: The tagname for the image built'
23+
value: ${{ jobs.build.outputs.tagname }}
24+
25+
jobs:
26+
build:
27+
name: Build & Push
28+
runs-on: ubuntu-22.04
29+
permissions:
30+
contents: read
31+
outputs:
32+
tagname: ${{ steps.tagname.outputs.tagname }}
33+
34+
steps:
35+
- name: Checkout Source Files
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
37+
38+
- name: Create a tagname
39+
id: tagname
40+
run: |
41+
tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)
42+
echo "tagname=$tagname" >> $GITHUB_ENV
43+
echo "tagname=$tagname" >> $GITHUB_OUTPUT
44+
45+
- name: Build & Tag Image
46+
run: |
47+
docker build \
48+
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ inputs.site_tld }}/curriculum-db:$tagname \
49+
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ inputs.site_tld }}/curriculum-db:latest \
50+
--file Dockerfile .
51+
52+
- name: Install doctl
53+
uses: digitalocean/action-doctl@58ec81179e2eaa350ef21d4df58f721c81ec2ba2 # v2
54+
with:
55+
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
56+
57+
- name: Log in to DigitalOcean Container Registry with short-lived credentials
58+
run: doctl registry login --expiry-seconds 1200
59+
60+
- name: Push image to DigitalOcean Container Registry
61+
run: |
62+
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ inputs.site_tld }}/curriculum-db:$tagname
63+
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ inputs.site_tld }}/curriculum-db:latest
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
name: CI - Node.js
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'prod-**'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.head_branch || github.ref }}
14+
cancel-in-progress: ${{ !contains(github.ref, 'main') && !contains(github.ref, 'prod-') }}
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
lint:
21+
name: Lint
22+
runs-on: ubuntu-22.04
23+
strategy:
24+
matrix:
25+
node-version: [22]
26+
fail-fast: false
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
31+
32+
- name: Check number of lockfiles
33+
run: |
34+
if [ $(find . -name 'package-lock.json' | grep -vc -e 'node_modules') -gt 0 ]
35+
then
36+
echo -e 'Error: found package-lock files in the repository.\nWe use pnpm workspaces to manage packages so all dependencies should be added via pnpm add'
37+
exit 1
38+
fi
39+
40+
- name: Use Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
45+
- name: Install pnpm
46+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
47+
id: pnpm-install
48+
with:
49+
run_install: false
50+
51+
- name: Install dependencies
52+
run: pnpm install
53+
54+
- name: Check formatting
55+
run: |
56+
pnpm format:check || [ $? -eq 1 ] && printf "\nTip: Run 'pnpm run format' in your terminal to fix this.\n\n"
57+
58+
- name: Lint
59+
run: pnpm lint
60+
61+
type-check:
62+
name: Type Check
63+
runs-on: ubuntu-22.04
64+
needs: lint
65+
strategy:
66+
matrix:
67+
node-version: [22]
68+
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
72+
73+
- name: Use Node.js ${{ matrix.node-version }}
74+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
75+
with:
76+
node-version: ${{ matrix.node-version }}
77+
78+
- name: Install pnpm
79+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
80+
id: pnpm-install
81+
with:
82+
run_install: false
83+
84+
- name: Install dependencies
85+
run: pnpm install
86+
87+
- name: Fetch curriculum data
88+
run: pnpm fetch-data
89+
90+
- name: Generate GraphQL types
91+
run: pnpm codegen
92+
93+
- name: Type check
94+
run: pnpm type-check
95+
96+
build:
97+
name: Build
98+
runs-on: ubuntu-22.04
99+
needs: type-check
100+
strategy:
101+
matrix:
102+
node-version: [22]
103+
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
107+
108+
- name: Use Node.js ${{ matrix.node-version }}
109+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
110+
with:
111+
node-version: ${{ matrix.node-version }}
112+
113+
- name: Install pnpm
114+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
115+
id: pnpm-install
116+
with:
117+
run_install: false
118+
119+
- name: Install dependencies
120+
run: pnpm install
121+
122+
- name: Fetch curriculum data
123+
run: pnpm fetch-data
124+
125+
- name: Build project
126+
run: pnpm build
127+
128+
- name: Upload build artifacts
129+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
130+
with:
131+
name: dist
132+
path: packages/server/dist
133+
retention-days: 7
134+
135+
test:
136+
name: Test
137+
runs-on: ubuntu-22.04
138+
needs: build
139+
strategy:
140+
fail-fast: false
141+
matrix:
142+
node-version: [22]
143+
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
147+
148+
- name: Use Node.js ${{ matrix.node-version }}
149+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
150+
with:
151+
node-version: ${{ matrix.node-version }}
152+
153+
- name: Install pnpm
154+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
155+
id: pnpm-install
156+
with:
157+
run_install: false
158+
159+
- name: Install dependencies
160+
run: pnpm install
161+
162+
- name: Fetch curriculum data
163+
run: pnpm fetch-data
164+
165+
- name: Run tests
166+
run: pnpm test
167+
168+
test-coverage:
169+
name: Test Coverage
170+
runs-on: ubuntu-22.04
171+
needs: test
172+
strategy:
173+
matrix:
174+
node-version: [22]
175+
176+
steps:
177+
- name: Checkout
178+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
179+
180+
- name: Use Node.js ${{ matrix.node-version }}
181+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
182+
with:
183+
node-version: ${{ matrix.node-version }}
184+
185+
- name: Install pnpm
186+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
187+
id: pnpm-install
188+
with:
189+
run_install: false
190+
191+
- name: Install dependencies
192+
run: pnpm install
193+
194+
- name: Fetch curriculum data
195+
run: pnpm fetch-data
196+
197+
- name: Run tests with coverage
198+
run: pnpm test:coverage
199+
200+
- name: Upload coverage reports
201+
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5
202+
if: always()
203+
with:
204+
files: ./coverage/coverage-final.json
205+
flags: unittests
206+
name: codecov-curriculum-db

0 commit comments

Comments
 (0)