Skip to content

Commit 1b83cc5

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

27 files changed

+1502
-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/ci.yml

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
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+
test-coverage:
176+
name: Test Coverage
177+
runs-on: ubuntu-latest
178+
needs: test
179+
steps:
180+
- name: Checkout code
181+
uses: actions/checkout@v4
182+
183+
- name: Setup Node.js
184+
uses: actions/setup-node@v4
185+
with:
186+
node-version: '22'
187+
188+
- name: Setup pnpm
189+
uses: pnpm/action-setup@v4
190+
with:
191+
version: 10.18.0
192+
193+
- name: Get pnpm store directory
194+
id: pnpm-cache
195+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
196+
197+
- name: Setup pnpm cache
198+
uses: actions/cache@v4
199+
with:
200+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
201+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
202+
restore-keys: |
203+
${{ runner.os }}-pnpm-store-
204+
205+
- name: Install dependencies
206+
run: pnpm install --frozen-lockfile
207+
208+
- name: Fetch curriculum data
209+
run: pnpm fetch-data
210+
211+
- name: Run tests with coverage
212+
run: pnpm test:coverage
213+
214+
- name: Upload coverage reports
215+
uses: codecov/codecov-action@v4
216+
if: always()
217+
with:
218+
files: ./coverage/coverage-final.json
219+
flags: unittests
220+
name: codecov-curriculum-db
221+
222+
docker-build:
223+
name: Docker Build Test
224+
runs-on: ubuntu-latest
225+
needs: build
226+
steps:
227+
- name: Checkout code
228+
uses: actions/checkout@v4
229+
230+
- name: Create tagname
231+
id: tagname
232+
run: |
233+
tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)
234+
echo "tagname=$tagname" >> $GITHUB_ENV
235+
echo "tagname=$tagname" >> $GITHUB_OUTPUT
236+
237+
- name: Set up Docker Buildx
238+
uses: docker/setup-buildx-action@v3
239+
240+
- name: Build Docker image
241+
run: |
242+
docker build \
243+
--tag freecodecamp/curriculum-db:${{ steps.tagname.outputs.tagname }} \
244+
--tag freecodecamp/curriculum-db:latest \
245+
--file Dockerfile .

0 commit comments

Comments
 (0)