This repository contains a complete Docker Compose setup for Apostrophe CMS with all required services.
- Status
- Services
- Get Started
- Development
- End-to-End Testing with Playwright
- Environment Variables
- Container Management
- DataBase Management
- Data Persistence
- Using Cursor AI for Git Operations
- PR Workflow
- Apostrophe CMS: The main web application
- MongoDB: Database for Apostrophe
- Redis: Optional caching server for better performance
- Mongo Express: Web-based MongoDB admin interface
Follow these steps to get the project up and running using Docker Compose:
Before you begin, ensure you have met the following requirements:
- Docker and Docker Compose.
- Git installed on your local machine.
- Node.js installed on your local machine.
- MongoDB Database Tools installed on your local machine.
- GitLab CLI installed on your local machine. This is required for creating and updating pull requests using Cursor AI.
git clone https://github.com/your-org/your-repo.git
cd your-repo
Navigate to the app directory with cd website/
, then run:
npm ci
Return to the repo root with cd ..
, then run:
docker compose up -d
docker exec -it apostrophe-cms node app @apostrophecms/user:add admin admin
mv 'your link to backup file' dump.archive
⚠️ Don't forget to adddump.archive
to your.gitignore
.
docker cp dump.archive apostrophe-mongodb:/tmp/dump.archive
docker exec -it apostrophe-mongodb mongosh --eval "db.getSiblingDB('apostrophe').dropDatabase()"
docker exec -it apostrophe-mongodb mongorestore --archive=/tmp/dump.archive --drop --nsFrom="a3-snf.*" --nsTo="apostrophe.*"
docker exec -it apostrophe-mongodb bash
ls -lh /tmp/dump.archive
exit
Then run:
docker exec -it apostrophe-mongodb bash -c "mongorestore --archive=/tmp/dump.archive --drop --nsFrom='a3-snf.*' --nsTo='apostrophe.*'"
docker-compose down
docker-compose up -d
For development with hot reloading, use:
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
This project uses Playwright for end-to-end testing.
-
Snapshot Management: To establish a baseline for UI tests, trigger the "Update Snapshots" workflow manually via the GitHub Actions UI. This builds the environment, runs Playwright tests with
--update-snapshots
, and uploads the snapshots as a GitHub Actions artifact. -
Automated E2E Testing: On every push request or PR, the "E2E Tests" workflow runs. It downloads the latest uploaded snapshots artifact and compares the current UI against it, ensuring UI consistency across branches.
Before testing, make sure the app is running at http://localhost:3000.
To run the end-to-end tests, go to the website/e2e
folder and run:
npm ci
Then, run the tests with:
npm run test:e2e
-
On the first run, this generates the initial snapshots in the
website/e2e/tests
folder. -
On subsequent runs, it compares the current UI state with the stored snapshots.
-
If you've made intentional UI changes, run
npm run test:e2e:update
to update the snapshots.
Environment variables are stored in the .env
file. For production, you should change:
SESSION_SECRET
: Set to a secure random stringNODE_ENV
: Change toproduction
- Start containers:
docker-compose up -d
- Stop containers:
docker-compose down
- View logs:
docker-compose logs -f
- Rebuild containers:
docker-compose up -d --build
- Import database:
MONGO_URI="mongodb://your-mongodb-uri" DB_NAME="your-database-name" ./scripts/import_mongodb.sh ./export
- Export database:
MONGO_URI="mongodb://your-mongodb-uri" DB_NAME="your-database-name" ./scripts/export_mongodb.sh
MongoDB and Redis data are stored in Docker volumes for persistence between restarts:
mongodb_data
redis_data
To remove all data and start fresh:
docker-compose down -v
You can easily commit your changes using Cursor AI by following these steps:
- Make your changes to the codebase
- Type "commit changes" in the AI chat
- Cursor AI will help you create a commit message following our standardized format:
- A descriptive title (max 120 characters)
- An empty line
- A bullet list of specific changes
Example chat message:
commit changes
This will trigger Cursor AI to analyze your changes and help you create a properly formatted commit following the rules in .cursor/rules/commit-changes-rules.mdc
.
To create or update a pull request using Cursor AI:
- Make sure your changes are committed
- Type "create pull request" or "update pull request" in the AI chat
- Cursor AI will help you format a proper PR following our standardized format:
- A descriptive title (max 120 characters)
- A bullet list of changes without repeating the title
- GitLab CLI will be used in the background to create or update the pull request
Example chat message:
create pull request
This will trigger Cursor AI to help you create a properly formatted PR, following the rules in .cursor/rules/pull-request-rules.mdc
.