feat(infra): add docker-compose for local MariaDB with Prisma schema init
Applies prisma/migrations/*/migration.sql on first container boot via a sourced docker-entrypoint-initdb.d script, so a fresh container matches a `prisma migrate deploy` run without needing shadow-database privileges. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:lts
|
||||
container_name: convert_mariadb
|
||||
restart: unless-stopped
|
||||
# Credentials below match .env.local (DB_HOST=127.0.0.1, DB_USER, DB_PASSWORD, DB_NAME).
|
||||
# Update both files together if you change any of these.
|
||||
environment:
|
||||
MARIADB_ROOT_PASSWORD: root_change_me
|
||||
MARIADB_DATABASE: file_converter
|
||||
MARIADB_USER: convert_user
|
||||
MARIADB_PASSWORD: change_me
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- mariadb_data:/var/lib/mysql
|
||||
# Raw SQL from prisma/migrations, applied on first boot by the init script below.
|
||||
- ./prisma/migrations:/prisma-migrations:ro
|
||||
- ./docker/mariadb-initdb:/docker-entrypoint-initdb.d:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
||||
start_period: 10s
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
volumes:
|
||||
mariadb_data:
|
||||
@@ -0,0 +1,10 @@
|
||||
# Sourced (non-executable) by mariadb-docker's entrypoint, which exposes
|
||||
# docker_process_sql and MARIADB_* env vars. Applies prisma/migrations/*/migration.sql
|
||||
# in order, so the container ends up schema-equivalent to a `prisma migrate deploy` run.
|
||||
for dir in /prisma-migrations/*/; do
|
||||
file="${dir}migration.sql"
|
||||
if [ -f "$file" ]; then
|
||||
mysql_note "Applying Prisma migration: $file"
|
||||
docker_process_sql --database="$MARIADB_DATABASE" < "$file"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user