Skip to content

hbz/strapi-rpb

Repository files navigation

Install a (local) strapi-rpb instance for development using Docker

You will get an strapi instance with the content model for rpb provided. User accounts and content entries are not included.

Set up

Install & set up Docker

Unix

Install Docker Engine by follwing the guide for your distro.

Install Docker Compose as a plugin.

Alternatively, you may want to use the Docker Desktop environment which includes a GUI and all Docker components.

Add your user to docker group

To execute docker commands without sudo, add your Unix user to the docker group, see https://docs.docker.com/engine/install/linux-postinstall/

Clone repo

$ git clone https://github.com/hbz/strapi-rpb.git
$ cd strapi-rpb

Add .env file

For starting the docker container you will need an .env file. You can use the example file:

$ cp .env.example .env

Development

For development on your local machine you can use Docker compose:

$ docker compose up

to spin up the two docker containers. The strapi app is accessible at http://localhost:1337/.

You first need to create an admin user via the GUI or via the CLI. (First, go into the container with $ docker exec -it strapi-rpb bash.)

In order to access the content-types through the REST API you need to set the appropriate permissions. Go to http://localhost:1337/admin/settings/users-permissions/roles, click on the respective role and set the permissions for each content-type. For more details please have a look at the docs of the Users & Permissions plugin.

Plugin

To open a bash in your container (e.g. to use strapi CLI commands), run:

$ docker exec -it strapi-rpb bash

To see changes made to the lookup plugin in your admin UI, run (in the project root directory):

$ cd -
$ strapi build

Config

Some config (e.g. field labels) is actually stored in the DB, not in repo files.

It can be dumped to a file inside the container and copied to the local repo with:

docker compose exec strapi-rpb strapi config:dump -f config.json
docker compose cp strapi-rpb:./opt/app/config.json .

Reverse for restoring from the file:

docker compose cp config.json strapi-rpb:./opt/app/
docker compose exec strapi-rpb strapi config:restore -f config.json

The current config dump is checked into the repo as config.json. Caution: credentials (eg. API Tokens) will also be dumped into this file. Be sure your config contains non-sensitiv data only. In doubt you should not commit your config.

When running the restore command you can choose from different strategies: replace (default), merge, keep.

Read more in the Strapi docs.

Deployment

To deploy changes, go to the repo directory, pull the changes, and rebuild the container (sudo docker compose -f docker-compose-prod.yml down ; sudo docker compose -f docker-compose-prod.yml up -d --build --force-recreate).

For details on our setup see https://dienst-wiki.hbz-nrw.de/display/SEM/RPB (internal).

Backup and restore

We create various daily backups for our test and productive instances:

  1. Backup Postgresql data directory: tar -czf [archivefile] data/, restore via restore-data-dir.sh
  2. SQL dump of database: pg_dump [database] -U [user] > | gzip > [dumpfile] Read more in the Postgresql docs
  3. Export strapi data: strapi export -- --file export_strapi_rpb --no-encrypt Read more in https://docs.strapi.io/cms/cli#strapi-export, restore https://docs.strapi.io/cms/cli#strapi-import
  4. Dump config: config:dump -f config.json-dump, see config:restore in https://docs.strapi.io/cms/cli#strapi-configuration-1
  5. Backup current docker image: docker image save --output [outputfile] strapi-rpb, restore https://docs.docker.com/reference/cli/docker/image/load/
  6. Backup edits written to disk: see #36

All backups mentioned above are run by cron. Check /etc/cron.d/ for the git versioned crontab that contains the specific backups commands and file paths.

About

strapi instance

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •