Migrated data dirs to mount instead of docker volume

Closes https://linear.app/ghost/issue/ENG-2413

- This makes migration from standard `ghost-cli` installs to Docker a bit easier and also tries to prevent people from accidentally pruning their Docker volumes are removing data
This commit is contained in:
James Loh
2025-06-23 14:03:18 +10:00
parent 0d2fad0878
commit 81893178fd
2 changed files with 9 additions and 5 deletions

View File

@@ -2,6 +2,12 @@
DOMAIN=example.com DOMAIN=example.com
# Location to store uploaded data
UPLOAD_LOCATION=./data/ghost
# Location for database data
MYSQL_DATA_LOCATION=./data/mysql
DATABASE_ROOT_PASSWORD=reallysecurerootpassword DATABASE_ROOT_PASSWORD=reallysecurerootpassword
DATABASE_USER=optionalusername DATABASE_USER=optionalusername
DATABASE_PASSWORD=ghostpassword DATABASE_PASSWORD=ghostpassword

View File

@@ -39,7 +39,7 @@ services:
tinybird__stats__id: ${TINYBIRD_ID:-} tinybird__stats__id: ${TINYBIRD_ID:-}
tinybird__stats__token: ${TINYBIRD_STATS_TOKEN:-} tinybird__stats__token: ${TINYBIRD_STATS_TOKEN:-}
volumes: volumes:
- ghost_content:/var/lib/ghost/content - ${UPLOAD_LOCATION:-./data/ghost}:/var/lib/ghost/content
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
@@ -67,7 +67,7 @@ services:
MYSQL_DATABASE: ghost MYSQL_DATABASE: ghost
MYSQL_MULTIPLE_DATABASES: activitypub MYSQL_MULTIPLE_DATABASES: activitypub
volumes: volumes:
- db_data:/var/lib/mysql - ${MYSQL_DATA_LOCATION:-./data/mysql}:/var/lib/mysql
- ./mysql-init:/docker-entrypoint-initdb.d - ./mysql-init:/docker-entrypoint-initdb.d
healthcheck: healthcheck:
test: mysql -u${DATABASE_USER:-ghost} -p${DATABASE_PASSWORD:?DATABASE_PASSWORD environment variable is required} ghost -e 'select 1' test: mysql -u${DATABASE_USER:-ghost} -p${DATABASE_PASSWORD:?DATABASE_PASSWORD environment variable is required} ghost -e 'select 1'
@@ -95,7 +95,7 @@ services:
expose: expose:
- "8080" - "8080"
volumes: volumes:
- ghost_content:/opt/activitypub/content - ${UPLOAD_LOCATION:-./data/ghost}:/opt/activitypub/content
environment: environment:
NODE_ENV: production NODE_ENV: production
PORT: 8080 PORT: 8080
@@ -167,8 +167,6 @@ services:
restart: no restart: no
volumes: volumes:
ghost_content:
db_data:
caddy_data: caddy_data:
caddy_config: caddy_config:
tinybird_files: tinybird_files: