Skip to content

Commit 90decbc

Browse files
committed
feat: deployment ready
1 parent 84248bc commit 90decbc

26 files changed

+1500
-1023
lines changed

.dockerignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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
63+
scripts/fetch-curriculum-data.sh
64+
scripts/fetch-curriculum-data.mjs
65+
66+
# Docker files (already in image context)
67+
Dockerfile
68+
docker-compose.yml
69+
.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/ci.yml

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
lint-and-format:
11+
name: Lint and Format Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '22'
21+
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 10.18.0
26+
27+
- name: Get pnpm store directory
28+
id: pnpm-cache
29+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
30+
31+
- name: Setup pnpm cache
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Lint
43+
run: pnpm lint
44+
45+
- name: Format check
46+
run: pnpm format:check
47+
48+
type-check:
49+
name: Type Check
50+
runs-on: ubuntu-latest
51+
needs: lint-and-format
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
56+
- name: Setup Node.js
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '22'
60+
61+
- name: Setup pnpm
62+
uses: pnpm/action-setup@v4
63+
with:
64+
version: 10.18.0
65+
66+
- name: Get pnpm store directory
67+
id: pnpm-cache
68+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
69+
70+
- name: Setup pnpm cache
71+
uses: actions/cache@v4
72+
with:
73+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
74+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
75+
restore-keys: |
76+
${{ runner.os }}-pnpm-store-
77+
78+
- name: Install dependencies
79+
run: pnpm install --frozen-lockfile
80+
81+
- name: Fetch curriculum data
82+
run: pnpm fetch-data
83+
84+
- name: Generate GraphQL types
85+
run: pnpm codegen
86+
87+
- name: Type check
88+
run: pnpm type-check
89+
90+
build:
91+
name: Build
92+
runs-on: ubuntu-latest
93+
needs: type-check
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
98+
- name: Setup Node.js
99+
uses: actions/setup-node@v4
100+
with:
101+
node-version: '22'
102+
103+
- name: Setup pnpm
104+
uses: pnpm/action-setup@v4
105+
with:
106+
version: 10.18.0
107+
108+
- name: Get pnpm store directory
109+
id: pnpm-cache
110+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
111+
112+
- name: Setup pnpm cache
113+
uses: actions/cache@v4
114+
with:
115+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
116+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
117+
restore-keys: |
118+
${{ runner.os }}-pnpm-store-
119+
120+
- name: Install dependencies
121+
run: pnpm install --frozen-lockfile
122+
123+
- name: Fetch curriculum data
124+
run: pnpm fetch-data
125+
126+
- name: Build project
127+
run: pnpm build
128+
129+
- name: Upload build artifacts
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: dist
133+
path: packages/server/dist
134+
retention-days: 7
135+
136+
test:
137+
name: Test
138+
runs-on: ubuntu-latest
139+
needs: type-check
140+
steps:
141+
- name: Checkout code
142+
uses: actions/checkout@v4
143+
144+
- name: Setup Node.js
145+
uses: actions/setup-node@v4
146+
with:
147+
node-version: '22'
148+
149+
- name: Setup pnpm
150+
uses: pnpm/action-setup@v4
151+
with:
152+
version: 10.18.0
153+
154+
- name: Get pnpm store directory
155+
id: pnpm-cache
156+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
157+
158+
- name: Setup pnpm cache
159+
uses: actions/cache@v4
160+
with:
161+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
162+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
163+
restore-keys: |
164+
${{ runner.os }}-pnpm-store-
165+
166+
- name: Install dependencies
167+
run: pnpm install --frozen-lockfile
168+
169+
- name: Fetch curriculum data
170+
run: pnpm fetch-data
171+
172+
- name: Run tests
173+
run: pnpm test
174+
175+
- name: Run performance tests
176+
run: pnpm test:perf
177+
178+
test-coverage:
179+
name: Test Coverage
180+
runs-on: ubuntu-latest
181+
needs: test
182+
steps:
183+
- name: Checkout code
184+
uses: actions/checkout@v4
185+
186+
- name: Setup Node.js
187+
uses: actions/setup-node@v4
188+
with:
189+
node-version: '22'
190+
191+
- name: Setup pnpm
192+
uses: pnpm/action-setup@v4
193+
with:
194+
version: 10.18.0
195+
196+
- name: Get pnpm store directory
197+
id: pnpm-cache
198+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
199+
200+
- name: Setup pnpm cache
201+
uses: actions/cache@v4
202+
with:
203+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
204+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
205+
restore-keys: |
206+
${{ runner.os }}-pnpm-store-
207+
208+
- name: Install dependencies
209+
run: pnpm install --frozen-lockfile
210+
211+
- name: Fetch curriculum data
212+
run: pnpm fetch-data
213+
214+
- name: Run tests with coverage
215+
run: pnpm test:coverage
216+
217+
- name: Upload coverage reports
218+
uses: codecov/codecov-action@v4
219+
if: always()
220+
with:
221+
files: ./coverage/coverage-final.json
222+
flags: unittests
223+
name: codecov-curriculum-db
224+
225+
docker-build:
226+
name: Docker Build Test
227+
runs-on: ubuntu-latest
228+
needs: build
229+
steps:
230+
- name: Checkout code
231+
uses: actions/checkout@v4
232+
233+
- name: Create tagname
234+
id: tagname
235+
run: |
236+
tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)
237+
echo "tagname=$tagname" >> $GITHUB_ENV
238+
echo "tagname=$tagname" >> $GITHUB_OUTPUT
239+
240+
- name: Set up Docker Buildx
241+
uses: docker/setup-buildx-action@v3
242+
243+
- name: Build Docker image
244+
run: |
245+
docker build \
246+
--tag freecodecamp/curriculum-db:${{ steps.tagname.outputs.tagname }} \
247+
--tag freecodecamp/curriculum-db:latest \
248+
--file Dockerfile .

0 commit comments

Comments
 (0)