Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ===========================================
# Pretexta - Environment Configuration
# ===========================================
# Copy this file to .env and fill in your values
# cp .env.example .env

# ---- Ports ----
FRONTEND_PORT=9443
BACKEND_PORT=9442
MONGO_PORT=47017

# ---- MongoDB ----
MONGO_USERNAME=soceng_admin
MONGO_PASSWORD=soceng_secure_password_2025
DB_NAME=Pretexta

# ---- JWT Secret (CHANGE IN PRODUCTION) ----
JWT_SECRET=change-this-secret-key-in-production

# ---- CORS Origins (comma-separated) ----
CORS_ORIGINS=http://localhost:9443,http://localhost:80

# ---- Frontend → Backend URL ----
REACT_APP_BACKEND_URL=http://localhost:9442
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install ruff
run: pip install ruff

- name: Lint
run: ruff check .

- name: Format check
run: ruff format --check .

frontend-lint:
name: Frontend Lint & Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
cache-dependency-path: frontend/yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Lint
run: yarn lint 2>/dev/null || true

- name: Build
run: yarn build

docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [backend-lint, frontend-lint]
steps:
- uses: actions/checkout@v4

- name: Build backend image
run: docker build -f Dockerfile.backend -t pretexta-backend:test .

- name: Build frontend image
run: docker build -f Dockerfile.frontend -t pretexta-frontend:test .
10 changes: 7 additions & 3 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM node:20-alpine as builder
FROM node:20-alpine AS builder

# Set working directory
WORKDIR /app

# Build arg — passed from docker-compose at build time
ARG REACT_APP_BACKEND_URL=http://localhost:9442
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL

# Copy package files
COPY frontend/package.json frontend/yarn.lock ./

Expand All @@ -12,7 +16,7 @@ RUN yarn install --frozen-lockfile
# Copy source code
COPY frontend/ .

# Build the application
# Build the application (REACT_APP_* env vars are baked in here)
RUN yarn build

# Production stage
Expand All @@ -28,4 +32,4 @@ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SocengLab Makefile

.PHONY: help install build up down restart logs clean test seed
.PHONY: help install build up down restart logs clean test seed lint lint-fix

# Default target
help:
Expand All @@ -23,6 +23,8 @@ help:
@echo " make logs-backend - Show backend logs only"
@echo " make logs-frontend - Show frontend logs only"
@echo " make test - Run tests"
@echo " make lint - Run backend linter"
@echo " make lint-fix - Auto-fix lint issues"
@echo ""
@echo "Maintenance:"
@echo " make clean - Remove containers and volumes"
Expand All @@ -37,20 +39,22 @@ install:

build:
@echo "Building Docker images..."
@if [ ! -f .env ]; then cp .env.example .env && echo "📋 Created .env from .env.example"; fi
@docker-compose build
@echo "✅ Docker images built"

up:
@echo "Starting Pretexta..."
@if [ ! -f .env ]; then cp .env.example .env && echo "📋 Created .env from .env.example"; fi
@docker-compose up -d
@echo "⏳ Waiting for services to start..."
@sleep 10
@echo ""
@echo "✅ Pretexta is running!"
@echo ""
@echo "🌐 Frontend: http://localhost:3000"
@echo "🔌 Backend API: http://localhost:8001"
@echo "🗄️ MongoDB: mongodb://localhost:27017"
@echo "🌐 Frontend: http://localhost:9443"
@echo "🔌 Backend API: http://localhost:9442"
@echo "🗄️ MongoDB: mongodb://localhost:47017"
@echo ""
@echo "📝 Default credentials: soceng / Cialdini@2025!"
@echo ""
Expand All @@ -76,7 +80,7 @@ logs-frontend:
@docker-compose logs -f frontend

db-shell:
@docker-compose exec mongodb mongosh -u soceng_admin -p soceng_secure_password_2025 --authenticationDatabase admin Pretexta
@docker-compose exec mongodb mongosh -u soceng_admin -p soceng_secure_password_2025 --authenticationDatabase admin Pretexta 2>/dev/null || docker compose exec mongodb mongosh -u soceng_admin -p soceng_secure_password_2025 --authenticationDatabase admin Pretexta

seed:
@echo "Importing sample challenges and quizzes..."
Expand All @@ -90,6 +94,18 @@ test:
@cd frontend && yarn test --watchAll=false
@echo "✅ Tests completed"

lint:
@echo "Linting backend..."
@cd backend && ruff check .
@cd backend && ruff format --check .
@echo "✅ Backend lint passed"

lint-fix:
@echo "Fixing backend lint issues..."
@cd backend && ruff check --fix .
@cd backend && ruff format .
@echo "✅ Backend lint fixed"

clean:
@echo "Cleaning up containers and volumes..."
@docker-compose down -v
Expand Down
Loading