CI/CD and Deployment Documentation
This directory contains the CI/CD configuration for the project.
Testing
The project includes end-to-end (e2e) tests to ensure the API endpoints work correctly. The tests are located in the backend/test
directory.
Running E2E Tests
# Navigate to the backend directory
cd backend
# Run e2e tests
npm run test:e2e
Test Structure
app.e2e-spec.ts
: Tests the basic API endpoint (/api)auth.e2e-spec.ts
: Tests authentication endpoints including:- User profile retrieval
- Token refresh
- GitHub OAuth redirection
test-utils.ts
: Utility functions for testing including:- Creating test applications
- Creating test users
- Generating authentication tokens
- Cleaning up test data
CI/CD Workflow
The CI/CD pipeline is configured using GitHub Actions and is defined in the .github/workflows/ci-cd.yml
file. The workflow consists of the following steps:
Build and Test
This job runs on every push to the main branch and on pull requests:
- Sets up Node.js and pnpm
- Installs dependencies
- Builds and tests the backend
- Builds and lints the frontend
Build and Push Docker Images
This job runs only on pushes to the main branch:
- Sets up Docker Buildx
- Logs in to GitHub Container Registry
- Builds and pushes the backend Docker image
- Builds and pushes the frontend Docker image
Deployment
The application is containerized using Docker. Dockerfiles are provided for both the backend and frontend:
backend/Dockerfile
: Multi-stage build for the NestJS backendfrontend/Dockerfile
: Multi-stage build for the Next.js frontend
A docker-compose.yml
file is also provided at the root of the project for local development and as a reference for deployment.
Running Locally with Docker Compose
# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
Environment Variables
The following environment variables are used in the deployment:
Backend
NODE_ENV
: Environment (development, production)PORT
: Port on which the backend runsPOSTGRES_HOST
: PostgreSQL hostPOSTGRES_PORT
: PostgreSQL portPOSTGRES_DB
: PostgreSQL database namePOSTGRES_USER
: PostgreSQL usernamePOSTGRES_PASSWORD
: PostgreSQL password
Frontend
NODE_ENV
: Environment (development, production)PORT
: Port on which the frontend runsNEXT_PUBLIC_API_URL
: URL of the backend API
Production Deployment Considerations
For production deployment, consider the following:
- Use a proper secrets management solution for sensitive information
- Set up proper networking and security groups
- Configure a reverse proxy (like Nginx) for SSL termination
- Set up monitoring and logging
- Configure database backups