Powered by Apostrophe CMS v3 Forked from apos-my-site boilerplate
- Git
- Node.js v14 or later
- MongoDB Community Server v5 or later
- (Optional) Docker (for testing production Docker image)
- Fork this repo on GitHub
- Clone your fork onto your local machine (
git clone https://github.com/<your username/matthewbrunetti.com
) cd
into the repo on your local machine (cd matthewbrunetti.com
)- Install dependencies (
npm install
) - Copy contents of
.env.example
into.env
- These defaults are good for local development, and you can edit this file at any time.
- Please be aware If you want to change
APOS_MONGODB_URI
, that value is overridden indocker-compose.yml
, used when running the app in Docker.
- Run app in dev mode:
npm run dev
- Run app in production mode:
npm run build && npm run serve
- Build and run production Docker image:
docker-compose up --build
- Restore local database from
db
folder:npm run db-restore
- Dump local database to
db
folder (requires MongoDB Database Tools):MONGODB_URI=mongodb://localhost/matthew-brunetti ./scripts/db-dump.sh
- Build the
Dockerfile
in the repo root - Configure:
- mount volume for
/app/public/uploads
- environment variables according to the .env.example
- Hint If you get errors about failed authentication when starting the app,
then you may need the
?authSource=admin
query param.
- Hint If you get errors about failed authentication when starting the app,
then you may need the
- mount volume for
- (Optional) Restore app data:
- Database. Restore from
db
folder /wMONGODB_URI=<connection-string> node scripts/restore-db
- Uploads. Copy files from
public/uploads
into the volume.
- Database. Restore from
- Start the container
- If you skipped the "Restore app data" step, log in with username "admin" password "admin" and edit this user.
This project has a GitHub Actions workflow that can be used to back up production data on a schedule and on-demand. It will back up both the database and the uploaded files. It uses the GitHub repo as storage, so you can easily work with production data in your development environment.
Backups go into the backup/prod
branch to be manually merged with the main
branch as desired.
When merging it is recommended to Squash and merge to keep the Git commit history clean.
To set up:
- (Optional) Enable scheduled backups by un-commenting the two lines near the top of
.github/workflows/back-up-prod.yml
. - Create a branch named
backup/prod
and push it to GitHub. - Add repository secrets on GitHub under Settings > Secrets > New repository secret:
MONGODB_URI
- e.g.mongodb://username:[email protected]:27017/databasename?authSource=admin
UPLOADS_DIR
- e.g.username:[email protected]:/path/to/public/uploads
(username and password are for SSH)
To trigger a backup on-demand, go to your project "Actions", select "Back up prod" from the list of workflows, click the "Run workflow" dropdown, and click the "Run workflow" button.