Skip to content

Commit 82a88a6

Browse files
Merge pull request #253 from guillermoscript/test
Test
2 parents 96961f5 + f8d1a1c commit 82a88a6

10 files changed

Lines changed: 152 additions & 28 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules
22
.next
33
.git
4+
.env*
45
supabase
56
tests
67
mcp-server

.github/workflows/deploy-mcp.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build and deploy MCP server to Dokploy
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
paths:
7+
- "mcp-server/**"
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}-mcp
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
tags: |
37+
type=raw,value=latest
38+
type=sha,prefix=
39+
40+
- name: Build and push Docker image
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: ./mcp-server
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
48+
- name: Trigger Dokploy deployment
49+
run: |
50+
curl -sSf -X POST "${{ secrets.DOKPLOY_MCP_DEPLOY_WEBHOOK_URL }}"

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and deploy to Dokploy
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Log in to GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34+
tags: |
35+
type=raw,value=latest
36+
type=sha,prefix=
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
build-args: |
46+
NEXT_PUBLIC_SUPABASE_URL=${{ vars.NEXT_PUBLIC_SUPABASE_URL }}
47+
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY=${{ vars.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY }}
48+
NEXT_PUBLIC_PLATFORM_DOMAIN=${{ vars.NEXT_PUBLIC_PLATFORM_DOMAIN }}
49+
NEXT_PUBLIC_APP_URL=${{ vars.NEXT_PUBLIC_APP_URL }}
50+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${{ vars.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
51+
52+
- name: Trigger Dokploy deployment
53+
run: |
54+
curl -sSf -X POST "${{ secrets.DOKPLOY_DEPLOY_WEBHOOK_URL }}"

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ WORKDIR /app
1313
COPY --from=deps /app/node_modules ./node_modules
1414
COPY . .
1515
ENV NEXT_TELEMETRY_DISABLED=1
16+
17+
# Next.js inlines NEXT_PUBLIC_* at build time — pass as build args
18+
ARG NEXT_PUBLIC_SUPABASE_URL
19+
ARG NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY
20+
ARG NEXT_PUBLIC_PLATFORM_DOMAIN
21+
ARG NEXT_PUBLIC_APP_URL
22+
ARG NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
23+
24+
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
25+
ENV NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY=$NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY
26+
ENV NEXT_PUBLIC_PLATFORM_DOMAIN=$NEXT_PUBLIC_PLATFORM_DOMAIN
27+
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
28+
ENV NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=$NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
29+
1630
RUN npm run build
1731

1832
# Production

app/[locale]/dashboard/admin/analytics/page.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export default async function AnalyticsPage({
2424
searchParams,
2525
}: {
2626
params: Promise<{ locale: string }>
27-
searchParams: SearchParams
27+
searchParams: Promise<SearchParams>
2828
}) {
2929
const { locale } = await params
30+
const resolvedSearchParams = await searchParams
3031
const t = await getTranslations('dashboard.admin.analytics')
3132
const tBreadcrumbs = await getTranslations('dashboard.admin.breadcrumbs')
3233
const dateLocale = locale === 'es' ? es : enUS
@@ -48,7 +49,7 @@ export default async function AnalyticsPage({
4849
const tenantId = await getCurrentTenantId()
4950

5051
// Get period from query params (default: 30 days)
51-
const period = searchParams.period || '30'
52+
const period = resolvedSearchParams.period || '30'
5253
const daysAgo = parseInt(period)
5354
const startDate = new Date()
5455
startDate.setDate(startDate.getDate() - daysAgo)
@@ -130,11 +131,11 @@ export default async function AnalyticsPage({
130131

131132
const { data: activeStudentIds } = await supabase
132133
.from('lesson_completions')
133-
.select('student_id')
134+
.select('user_id')
134135
.eq('tenant_id', tenantId)
135136
.gte('completed_at', thirtyDaysAgo.toISOString())
136137

137-
const activeStudents = new Set(activeStudentIds?.map((s) => s.student_id)).size
138+
const activeStudents = new Set(activeStudentIds?.map((s) => s.user_id)).size
138139

139140
const { count: totalLessonCompletions } = await supabase
140141
.from('lesson_completions')
@@ -174,7 +175,7 @@ export default async function AnalyticsPage({
174175
const { count: completedLessons } = await supabase
175176
.from('lesson_completions')
176177
.select('*', { count: 'exact', head: true })
177-
.eq('student_id', (enrollment as any).student_id)
178+
.eq('user_id', (enrollment as any).user_id)
178179
.in(
179180
'lesson_id',
180181
(
@@ -245,7 +246,7 @@ export default async function AnalyticsPage({
245246
const { count: completedCount } = await supabase
246247
.from('lesson_completions')
247248
.select('*', { count: 'exact', head: true })
248-
.eq('student_id', enrollment.user_id)
249+
.eq('user_id', enrollment.user_id)
249250
.in('lesson_id', lessonIds)
250251

251252
totalCompletions += (completedCount || 0) / lessonIds.length

app/[locale]/dashboard/admin/users/[userId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default async function UserDetailPage({ params }: PageProps) {
105105
)
106106
)
107107
`)
108-
.eq('student_id', userId)
108+
.eq('user_id', userId)
109109
.eq('tenant_id', tenantId)
110110
.order('completed_at', { ascending: false })
111111
.limit(10)

app/api/seed-test-data/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ export async function POST() {
104104
const lessonCompletions = [
105105
// Course 1: 2 out of 3 lessons
106106
{
107-
student_id: studentUserId,
107+
user_id: studentUserId,
108108
lesson_id: 1,
109109
completed_at: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString()
110110
},
111111
{
112-
student_id: studentUserId,
112+
user_id: studentUserId,
113113
lesson_id: 2,
114114
completed_at: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString()
115115
},
116116
// Course 3: 1 out of 24 lessons
117117
{
118-
student_id: studentUserId,
118+
user_id: studentUserId,
119119
lesson_id: 8,
120120
completed_at: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString()
121121
}
@@ -125,7 +125,7 @@ export async function POST() {
125125
const { error: completionError } = await supabase
126126
.from('lesson_completions')
127127
.upsert(completion, {
128-
onConflict: 'student_id,lesson_id'
128+
onConflict: 'user_id,lesson_id'
129129
})
130130

131131
if (completionError) {

mcp-server/Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS builder
22

3-
# Set working directory
43
WORKDIR /app
54

6-
# Copy package files
75
COPY package*.json ./
6+
RUN npm ci
87

9-
# Install production dependencies only
8+
COPY tsconfig.json ./
9+
COPY src ./src
10+
RUN npm run build
11+
12+
FROM node:20-alpine AS runner
13+
14+
WORKDIR /app
15+
16+
COPY package*.json ./
1017
RUN npm ci --production --ignore-scripts
1118

12-
# Copy built files
13-
COPY build ./build
19+
COPY --from=builder /app/build ./build
1420

15-
# Expose MCP server port
1621
EXPOSE 3001
1722

18-
# Health check
23+
ENV MCP_HTTP_HOST=0.0.0.0
24+
1925
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
2026
CMD node -e "require('http').get('http://localhost:3001', (res) => process.exit(res.statusCode === 404 ? 0 : 1))"
2127

22-
# Run HTTP server
2328
CMD ["node", "build/http-server.js"]

scripts/seed-playwright.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ async function main() {
426426
const { error: delComErr } = await supabase
427427
.from('lesson_completions')
428428
.delete()
429-
.eq('student_id', userId)
430-
.eq('course_id', courseId)
429+
.eq('user_id', userId)
431430

432431
if (delComErr) console.warn('Warning deleting lesson_completions:', delComErr.message)
433432

scripts/seed-test-enrollments.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,23 @@ BEGIN
6565

6666
-- Add lesson completions for Course 1 (2 out of 3 lessons completed)
6767
-- Lesson 1: Completed
68-
INSERT INTO lesson_completions (student_id, lesson_id, completed_at)
68+
INSERT INTO lesson_completions (user_id, lesson_id, completed_at)
6969
VALUES (student_user_id, 1, NOW() - INTERVAL '6 days')
70-
ON CONFLICT (student_id, lesson_id) DO NOTHING;
70+
ON CONFLICT (user_id, lesson_id) DO NOTHING;
7171

7272
-- Lesson 2: Completed
73-
INSERT INTO lesson_completions (student_id, lesson_id, completed_at)
73+
INSERT INTO lesson_completions (user_id, lesson_id, completed_at)
7474
VALUES (student_user_id, 2, NOW() - INTERVAL '5 days')
75-
ON CONFLICT (student_id, lesson_id) DO NOTHING;
75+
ON CONFLICT (user_id, lesson_id) DO NOTHING;
7676

7777
-- Lesson 3: Not completed (to show "In Progress" status)
7878

7979
RAISE NOTICE 'Created 2/3 lesson completions for Course 1';
8080

8181
-- Add lesson completion for Course 3 (1 out of 24 lessons completed)
82-
INSERT INTO lesson_completions (student_id, lesson_id, completed_at)
82+
INSERT INTO lesson_completions (user_id, lesson_id, completed_at)
8383
VALUES (student_user_id, 8, NOW() - INTERVAL '2 days')
84-
ON CONFLICT (student_id, lesson_id) DO NOTHING;
84+
ON CONFLICT (user_id, lesson_id) DO NOTHING;
8585

8686
RAISE NOTICE 'Created 1/24 lesson completion for Course 3';
8787

0 commit comments

Comments
 (0)