natureinpots_community/docker-compose.yml
2025-05-18 01:00:52 -05:00

90 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/app
environment:
- FLASK_APP=app
- FLASK_ENV=development
- USE_REMOTE_MYSQL=${USE_REMOTE_MYSQL}
- ENABLE_DB_SEEDING=${ENABLE_DB_SEEDING}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_HOST=${MYSQL_HOST}
- MYSQL_PORT=${MYSQL_PORT}
depends_on:
- db
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 10s
timeout: 5s
retries: 5
command: >
bash -c "
set -e
echo '[✔] Ensuring .env...'
if [ ! -f '.env' ]; then cp .env.example .env; fi
echo '[✔] Waiting for MySQL to be ready...'
until nc -z ${MYSQL_HOST} ${MYSQL_PORT}; do sleep 1; done
echo '[✔] Ensuring migration structure...'
if [ ! -d 'migrations' ]; then
echo '[] Running flask db init...'
flask db init
fi
echo '[] Autogenerating migration...'
flask db migrate -m 'auto' || echo '[] No changes detected.'
echo '[✔] Running DB migrations...'
flask db upgrade
if [ \"$$ENABLE_DB_SEEDING\" = \"1\" ]; then
echo '[🌱] Seeding admin user...'
flask seed-admin
else
echo '[⚠️] DB seeding skipped by config.'
fi
echo '[🚀] Starting Flask server...'
flask run --host=0.0.0.0
"
db:
image: mysql:8
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "3306:3306"
volumes:
- plant_price_tracker_mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
adminer:
image: adminer
restart: always
ports:
- 8080:8080
environment:
ADMINER_DEFAULT_SERVER: db
depends_on:
- db
volumes:
plant_price_tracker_mysql_data: