fix linter and document permission required by the respective container UID

This commit is contained in:
Kwee Lung Sin 2026-09-08 00:50:55 +07:00
parent 9194626bcd
commit d2a336d44e
No known key found for this signature in database
7 changed files with 57 additions and 5 deletions

View File

@ -55,10 +55,24 @@ Then edit `.env` and set variables according to your needs.
| `DB_DATA_LOCATION` | Host directory for the `db-data` volume; must be an absolute path and already exist | - | Required for `compose.bind-mount-db-data.yaml` |
| `REDIS_QUEUE_DATA_LOCATION` | Host directory for the `redis-queue-data` volume; must be an absolute path and already exist | - | Required for `compose.bind-mount-redis-queue.yaml` |
The host directory must exist before `docker compose up -d` and must be writable by the user the container runs as:
| Directory | Owner |
| ------------------ | ------------------------------------------------- |
| `sites` | uid/gid `1000` (the `frappe` user of the image) |
| `db-data` | uid/gid `999` (the `mariadb` or `postgres` image) |
| `redis-queue-data` | uid/gid `999` (the `redis` image) |
> Warning: with a bind mount, the data lives on the host, not inside the Docker volume. Removing the volume (for example with `docker compose down -v`) will **not** delete the data. To actually erase the data, delete the host directory manually with `rm -r <data path>`.
**Example:**
```bash
mkdir -p /srv/frappe/{sites,db-data,redis-queue-data}
chown 1000:1000 /srv/frappe/sites
chown 999:999 /srv/frappe/db-data /srv/frappe/redis-queue-data
```
```bash
SITES_DATA_LOCATION=/srv/frappe/sites
DB_DATA_LOCATION=/srv/frappe/db-data

View File

@ -29,7 +29,7 @@ docker compose -f compose.yaml -f overrides/compose.mariadb.yaml -f overrides/co
| compose.migrator.yaml | Runs a dedicated migration container performing `bench --site all migrate` on all sites at every start | Control migration intent with `MIGRATE_SITES` - defaults to true |
| **Volumes** | | |
| compose.bind-mount-sites.yaml | Bind mounts the `sites` volume to a host directory instead of a Docker-managed volume | Set `SITES_DATA_LOCATION`. The directory must exist before `docker compose up -d`. |
| compose.bind-mount-db-data.yaml | Bind mounts the `db-data` volume to a host directory instead of a Docker-managed volume | Use with `compose.mariadb.yaml` or `compose.postgres.yaml`. Set `DB_DATA_LOCATION`. The directory must exist before `docker compose up -d`. |
| compose.bind-mount-db-data.yaml | Bind mounts the `db-data` volume to a host directory instead of a Docker-managed volume | Use with a database override (mariadb, mariadb-shared, postgres). Set `DB_DATA_LOCATION`. Directory must exist before `docker compose up -d`. |
| compose.bind-mount-redis-queue.yaml | Bind mounts the `redis-queue-data` volume to a host directory instead of a Docker-managed volume | Use with `compose.redis.yaml`. Set `REDIS_QUEUE_DATA_LOCATION`. The directory must exist before `docker compose up -d`. |
| **TBD** | **The following overrides are available but lack documentation. If you use them and understand their purpose, please consider contributing to this documentation.** | |
| compose.backup-cron.yaml | | |

View File

@ -15,6 +15,12 @@ DB_PORT=
REDIS_CACHE=
REDIS_QUEUE=
# Only with the bind mount overrides.
# Absolute path to an existing host directory, owned by the uid/gid the service runs as (1000 for sites, 999 for db-data and redis-queue-data).
SITES_DATA_LOCATION=
DB_DATA_LOCATION=
REDIS_QUEUE_DATA_LOCATION=
# The number of threads per Gunicorn worker process for handling concurrent requests.
GUNICORN_THREADS=4

View File

@ -1,14 +1,17 @@
# Bind mount the `db-data` volume to a host directory instead of letting Docker manage it.
# Use together with overrides/compose.mariadb.yaml or overrides/compose.postgres.yaml.
# Use together with overrides/compose.mariadb.yaml, overrides/compose.mariadb-shared.yaml or
# overrides/compose.postgres.yaml.
#
# NOTE:
# - `DB_DATA_LOCATION` (required): absolute path to the host directory to bind mount.
# - The directory must exist before running `docker compose up -d`, otherwise Docker fails
# when populating the volume.
# - The directory must be writable by the database user of the image: uid/gid 999 for both
# the `mariadb` and the `postgres` images, for example `chown -R 999:999 <path>`.
volumes:
db-data:
driver: local
driver_opts:
type: none
o: bind
device: ${DB_DATA_LOCATION}
device: ${DB_DATA_LOCATION:?DB_DATA_LOCATION must be set to an existing absolute host path}

View File

@ -5,10 +5,12 @@
# - `REDIS_QUEUE_DATA_LOCATION` (required): absolute path to the host directory to bind mount.
# - The directory must exist before running `docker compose up -d`, otherwise Docker fails
# when populating the volume.
# - The directory must be writable by the `redis` user of the image (uid/gid 999):
# `chown -R 999:999 <path>`.
volumes:
redis-queue-data:
driver: local
driver_opts:
type: none
o: bind
device: ${REDIS_QUEUE_DATA_LOCATION}
device: ${REDIS_QUEUE_DATA_LOCATION:?REDIS_QUEUE_DATA_LOCATION must be set to an existing absolute host path}

View File

@ -4,10 +4,12 @@
# - `SITES_DATA_LOCATION` (required): absolute path to the host directory to bind mount.
# - The directory must exist before running `docker compose up -d`, otherwise Docker fails
# when populating the volume.
# - The directory must be writable by the `frappe` user of the image (uid/gid 1000):
# `chown -R 1000:1000 <path>`.
volumes:
sites:
driver: local
driver_opts:
type: none
o: bind
device: ${SITES_DATA_LOCATION}
device: ${SITES_DATA_LOCATION:?SITES_DATA_LOCATION must be set to an existing absolute host path}

View File

@ -2,10 +2,13 @@
"environment": {
"BASE_SITE": "site-one.localhost",
"BENCH_NETWORK": "bench-network",
"DB_DATA_LOCATION": "/srv/frappe-bind-mounts/db-data",
"DB_PASSWORD_SECRETS_FILE": "./test-db-password.txt",
"EMAIL": "admin@example.com",
"HASHED_PASSWORD": "not-a-real-password-hash",
"REDIS_QUEUE_DATA_LOCATION": "/srv/frappe-bind-mounts/redis-queue-data",
"ROUTER": "site-one",
"SITES_DATA_LOCATION": "/srv/frappe-bind-mounts/sites",
"TRAEFIK_DOMAIN": "traefik.example.com"
},
"configurations": [
@ -37,6 +40,28 @@
"overrides/compose.noproxy.yaml"
]
},
{
"name": "mariadb-bind-mounts",
"files": [
"compose.yaml",
"overrides/compose.mariadb.yaml",
"overrides/compose.redis.yaml",
"overrides/compose.noproxy.yaml",
"overrides/compose.bind-mount-sites.yaml",
"overrides/compose.bind-mount-db-data.yaml",
"overrides/compose.bind-mount-redis-queue.yaml"
]
},
{
"name": "postgres-bind-mount-db-data",
"files": [
"compose.yaml",
"overrides/compose.postgres.yaml",
"overrides/compose.redis.yaml",
"overrides/compose.noproxy.yaml",
"overrides/compose.bind-mount-db-data.yaml"
]
},
{
"name": "traefik-http",
"files": [