Sign inSign up

netronaut/strapi

By netronaut

•Updated over 4 years ago

Docker image for strapi.io headless CMS

Image
0

358

netronaut/strapi repository overview

⁠Docker image for strapi.io headless CMS

Versions:

This Docker image contains a pre-installed version of strapi.io headless CMS.

Strapi and base dependencies are already installed in node_modules.

Additionally there's sqlite installed to create and restore backups (see Backup⁠).

⁠Run image

Strapi needs API secrets to run. Provide these via .env-file:

APP_KEYS=<array of four keys, separated by comma>
JWT_SECRET=<key>
API_TOKEN_SALT=<key>

You may generate an .env file with api keys using this script:

node ./generate-api-keys.js > .env

Now run strapi. Don't forget to attach ports and any volume you need:

docker run --rm --env-file .env --name netronaut_strapi -d -p 1337:1337 netronaut/strapi

Volumes to mount:

VOLUME /srv/app/config
VOLUME /srv/app/database
VOLUME /srv/app/public
VOLUME /srv/app/src

Most of the time you want to mount /srv/app/src in order to develop.

To extend strapi with extensions and custom configuration, use the /srv/app/config volume.

Example:

docker run
  --rm
  --env-file .env
  --name netronaut_strapi
  -p 1337:1337
  -v `pwd`/src:/srv/app/src
  -d
  netronaut/strapi
⁠Compose file

You may want to use docker compose or another CLI to run from a docker-compose.yml like this:

version: '3'
services:
  strapi:
    image: netronaut/strapi
    volumes:
      - './strapi/src:/srv/app/src'
      - './strapi/config:/srv/app/config'
    ports:
      - 1337:1337
    env_file:
      - .env

⁠Database

This image works with sqlite per default. The data is stored inside the container under <WORKDIR>/.tmp/data.db.

You can use sqlite during development. Once you are ready to go to production, you might want to dump the data to an .sql file.

⁠Backup

Backup data to .sql file:

docker exec netronaut_strapi sh -c 'sqlite .tmp/data.db ".dump"' > backup.sql
⁠Restore

Restore the database from .sql file:

docker cp backup.sql netronaut_strapi:/srv/app/backup.sh
docker exec netronaut_strapi sh -c 'sqlite .tmp/data.db ".read backup.sh"'

Tag summary

Content type

Image

Digest

Size

211.3 MB

Last updated

over 4 years ago

docker pull netronaut/strapi