# Start all services
docker compose up
# Access your application:
# - Frontend: http://localhost:3000
# - Strapi Admin: http://localhost:1337/admin
# - Database Admin: http://localhost:5050
# - Mail Server: http://localhost:8025# Build and run production-like environment
docker compose -f compose.mimic-prod.yml up --build
# Access via Nginx reverse proxy:
# - Application: http://localhost
# - CMS: http://localhost/cms${PROJECT_DIR}/
βββ backend/ # Strapi CMS
β βββ __tests__/ # Backend test files
β β βββ helpers/ # Test utilities
β β βββ api/ # API endpoint tests
β β βββ controllers/ # Controller tests
β β βββ models/ # Model/Service tests
β βββ config/ # Strapi configuration
β βββ src/ # API routes and controllers
β βββ scripts/ # Startup and utility scripts
β βββ jest.config.js # Jest configuration
β βββ Dockerfile # Production build
β βββ Dockerfile-dev # Development build
βββ frontend/ # Next.js Application
β βββ __tests__/ # Frontend test files
β β βββ components/ # Component tests
β β βββ lib/ # Utility tests
β β βββ pages/ # Page tests
β β βββ __snapshots__/ # Jest snapshots
β βββ src/ # Application source code
β βββ jest.config.js # Jest configuration
β βββ jest.setup.js # Jest setup file
β βββ Dockerfile # Production build
β βββ docker-entrypoint.sh # Runtime environment injection
βββ nginx/ # Nginx reverse proxy
β βββ conf.d/ # Nginx configuration
βββ db/ # Database initialization
β βββ docker-entrypoint-initdb.d/
βββ pgadmin4/ # Database administration
βββ TESTING.md # Testing documentation
βββ compose.yml # Development environment
βββ compose.mimic-prod.yml # Production simulation
| Service | Port | Description |
|---|---|---|
| Frontend | 3000 | Next.js development server |
| Backend | 1337 | Strapi CMS with hot reload |
| Database | 5432 | PostgreSQL with persistent storage |
| PgAdmin | 5050 | Database administration interface |
| Mailpit | 8025 | Email testing and preview |
- URL: http://localhost:1337
- Admin Panel: http://localhost:1337/admin
- API Endpoint: http://localhost:1337/api
- File Uploads: Persistent volume mounted
- Hot Reload: Enabled via volume mounts
- URL: http://localhost:3000
- Hot Reload: Enabled with fast refresh
- API Proxy: Configured to backend
- Environment Variables: Runtime injection
- Host: localhost:5432
- Database: ${PROJECT_DIR}
- Username: akvo
- Password: password
- Admin Interface: http://localhost:5050
- SMTP: localhost:1025
- Web Interface: http://localhost:8025
- Features: Email preview, testing, debugging
# Start development environment
docker compose up
# View logs
docker compose logs -f [service_name]
# Rebuild specific service
docker compose up --build [service_name]
# Stop all services
docker compose down
# Reset database (destructive)
docker compose down -v# Build and start production environment
docker compose -f compose.mimic-prod.yml up --build
# Scale services
docker compose -f compose.mimic-prod.yml up --scale frontend=2
# View production logs
docker compose -f compose.mimic-prod.yml logs# Access database directly
docker compose exec db psql -U akvo -d ${PROJECT_DIR}
# Backup database
docker compose exec db pg_dump -U akvo ${PROJECT_DIR} > backup.sql
# Restore database
cat backup.sql | docker compose exec -T db psql -U akvo -d ${PROJECT_DIR}DATABASE_*: PostgreSQL connection settingsJWT_SECRET: Authentication token secretAPP_KEYS: Strapi application keysSMTP_*: Email server configurationGCS_*: Google Cloud Storage (optional)
NEXT_PUBLIC_BACKEND_URL: API endpoint URLNEXT_TELEMETRY_DISABLED: Disable Next.js telemetry
The setup includes Mailpit for email testing:
- SMTP server runs on port 1025
- Web interface available at http://localhost:8025
- All emails are captured and can be viewed in the interface
- Update all environment variables with production values
- Configure SSL certificates in Nginx
- Set up proper database credentials
- Configure external storage (GCS/S3) for file uploads
- Set up monitoring and logging
- Configure backup strategies
# Build production images
docker build -t ${PROJECT_DIR}-backend ./backend
docker build -t ${PROJECT_DIR}-frontend ./frontend
docker build -t ${PROJECT_DIR}-nginx ./nginx
# Push to registry
docker tag ${PROJECT_DIR}-backend your-registry/${PROJECT_DIR}-backend:latest
docker push your-registry/${PROJECT_DIR}-backend:latest- Default credentials are used for convenience
- All services are exposed on localhost
- Debug mode is enabled
- Change all default passwords and secrets
- Use environment variables for sensitive data
- Implement proper SSL/TLS
- Configure firewall rules
- Enable audit logging
This project includes comprehensive testing infrastructure for both backend and frontend.
# Run all backend tests
cd backend && npm test
# Run all frontend tests
cd frontend && npm test
# Run tests in Docker
docker compose exec backend npm test
docker compose exec frontend npm testTest Scripts:
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage report
npm run test:ci # Run tests in CI modeTest Structure:
backend/__tests__/
βββ helpers/
β βββ setup.js # Test environment setup
β βββ strapi.js # Strapi test utilities
βββ api/
β βββ health.test.js # API endpoint tests
β βββ auth.test.js # Authentication tests
βββ controllers/
β βββ example.test.js # Controller tests
βββ models/
βββ example.test.js # Model/Service tests
Example Test:
const request = require('supertest');
const { setupStrapi, getStrapi } = require('../helpers/strapi');
describe('API Endpoint', () => {
beforeAll(async () => await setupStrapi());
it('should return data', async () => {
const strapi = getStrapi();
const response = await request(strapi.server.httpServer)
.get('/api/your-endpoint')
.expect(200);
expect(response.body.data).toBeDefined();
});
});Test Scripts:
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage report
npm run test:update # Update snapshots
npm run test:ci # Run tests in CI modeTest Structure:
frontend/__tests__/
βββ components/
β βββ Button.test.jsx # Component unit tests
β βββ Card.snapshot.test.jsx # Snapshot tests
β βββ Form.interaction.test.jsx # Interaction tests
βββ lib/
β βββ strapi.test.js # Utility function tests
β βββ test-utils.jsx # Custom test utilities
βββ pages/
βββ Home.test.jsx # Page component tests
Test Types Included:
- Unit Tests: Test individual components and functions
- Interaction Tests: Test user interactions with @testing-library/user-event
- Snapshot Tests: Catch unintended UI changes
Example Test:
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
describe('Button', () => {
it('calls onClick when clicked', async () => {
const handleClick = jest.fn();
const user = userEvent.setup();
render(<Button onClick={handleClick}>Click me</Button>);
await user.click(screen.getByText('Click me'));
expect(handleClick).toHaveBeenCalled();
});
});After running `npm run test:coverage`, view reports at:
- Backend: `backend/coverage/lcov-report/index.html`
- Frontend: `frontend/coverage/lcov-report/index.html`
# Example GitHub Actions workflow
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: cd backend && npm ci && npm run test:ci
- run: cd frontend && npm ci && npm run test:ciFor detailed testing documentation, see TESTING.md.
- Strapi v4 - Headless CMS
- Next.js 14 - React Framework
- PostgreSQL 16 - Database
- Docker - Containerization
- Nginx - Reverse Proxy
- Strapi automatically generates API documentation
- Access via: http://localhost:1337/documentation (if enabled)
- GraphQL playground: http://localhost:1337/graphql (if enabled)
# Check for port usage
lsof -i :3000
lsof -i :1337
lsof -i :5432
# Kill processes if needed
npx kill-port 3000 1337 5432# Reset database
docker compose down -v
docker compose up db
# Wait for database to be ready, then start other services# Clean Docker cache
docker system prune -f
docker builder prune -f
# Rebuild without cache
docker compose build --no-cache# Fix file permissions (if needed)
sudo chown -R $USER:$USER .# View all logs
docker compose logs
# Follow specific service logs
docker compose logs -f backend
docker compose logs -f frontend
# Debug mode
DEBUG=* docker compose up- Make changes to source code
- Test locally with
docker compose up - Verify production build with
docker compose -f compose.mimic-prod.yml up - Submit pull request
- Backend: Follow Strapi conventions
- Frontend: Use Prettier and ESLint
- Commit messages: Follow conventional commits
This project is licensed under the MIT License - see the LICENSE file for details.
- Content Modeling: Create your content types in Strapi admin
- Frontend Development: Build your pages and components
- API Integration: Connect frontend to Strapi API
- Authentication: Implement user authentication if needed
- Deployment: Configure production environment
Happy coding! π