Docker Compose: one container with SQLite
This is the set-up we suggest for a small choir that wants Docker: one container, SQLite for the database and the container's volume for uploaded files. Back up the one volume and you have backed up everything. It is for whoever manages the server.
You need Docker with the Compose plugin (the command is docker compose), and the folder from Run it in Docker: the unpacked download with the Dockerfile, .dockerignore and .env you made there. This page adds a Compose file that wraps the same image.
The Compose file
Create docker-compose.sqlite.yml in that folder:
services:
app:
build: .
image: choir-manager
restart: unless-stopped
env_file: .env
environment:
NODE_ENV: production
PORT: 3001
DB_PROVIDER: sqlite
SQLITE_PATH: /app/data/choir.sqlite
STORAGE_PROVIDER: local
STORAGE_LOCAL_DIR: /app/data/storage
SESSION_STORE: database
ports:
- "${HTTP_PORT:-8080}:3001"
volumes:
- data:/app/data
volumes:
data:
The same file ships with the source code of the product, and this one was run for this guide with the image from the previous page.
What it says
| Line | Meaning |
|---|---|
build: . and image: choir-manager | Build the image from the Dockerfile in this folder and call it choir-manager. |
restart: unless-stopped | Start it again after a crash or a reboot. |
env_file: .env | Your settings go in. |
environment: | Fixed values that override the same names in .env: production mode, port 3001, the database at /app/data/choir.sqlite, local files at /app/data/storage, and sessions in the database. |
ports | Publish the container's port 3001 on the host's port HTTP_PORT, or 8080 if that is not set. |
volumes: data:/app/data | The one named volume. It holds the database, uploads, downloaded releases (releases/) and the copies of the database made before an update (backups/). |
Add HTTP_PORT=8080 (or another port) to .env if you want to change the port. Compose reads .env in this folder for the ${HTTP_PORT} above, and also passes it to the container, where it does no harm.
Bring it up
docker compose -f docker-compose.sqlite.yml up -d --build
Check it:
docker compose -f docker-compose.sqlite.yml ps
curl http://localhost:8080/api/health
docker compose -f docker-compose.sqlite.yml logs app
After about 15 seconds ps shows the app as healthy, and the health answer is {"status":"ok","platform":"node","version":"1.6.12"}. The log has [launcher] starting 1.6.12 and [server] version 1.6.12 listening on ... (production).
On macOS and Windows, the volume lives inside Docker's virtual machine. On Linux, it is under /var/lib/docker/volumes.
Run the helper commands
Run them in the running container with exec:
docker compose -f docker-compose.sqlite.yml exec app npm run config:check
docker compose -f docker-compose.sqlite.yml exec app npm run admin:add -- someone@example.org "Their Name"
docker compose -f docker-compose.sqlite.yml exec app node scripts/seed-demo.js
The exec runs as the container's user node, with the container's settings, so the answers are what the server itself sees. See Check your configuration.
Stop, restart, update the settings
docker compose -f docker-compose.sqlite.yml stop
docker compose -f docker-compose.sqlite.yml start
docker compose -f docker-compose.sqlite.yml up -d # after changing .env: recreates the container
docker compose -f docker-compose.sqlite.yml down # removes the container; the volume stays
down -v also deletes the volume, and with it your database and uploads.
Put HTTPS in front
The site is on http://<host>:8080. A real site must be on HTTPS, so put a proxy in front: Put it behind HTTPS (point it at localhost:8080), or use the Caddy service in Docker: HTTPS, ports and volumes.
Back up
The volume is the whole site. See Back up a single-server site. Its name is the folder's name with _data, such as choir-docker_data; docker volume ls shows it.