155 lines
4.1 KiB
YAML
155 lines
4.1 KiB
YAML
services:
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.prod
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8083-8085:${PORT}"
|
|
environment:
|
|
APP_ENV: ${APP_ENV}
|
|
PORT: ${PORT}
|
|
GIN_MODE: release
|
|
BLUEPRINT_DB_HOST: mysql_bp
|
|
BLUEPRINT_DB_PORT: ${BLUEPRINT_DB_PORT}
|
|
BLUEPRINT_DB_DATABASE: ${BLUEPRINT_DB_DATABASE}
|
|
BLUEPRINT_DB_USERNAME: root
|
|
BLUEPRINT_DB_PASSWORD: ${BLUEPRINT_DB_ROOT_PASSWORD}
|
|
BLUEPRINT_DB_MAX_IDLE_CONNS: ${BLUEPRINT_DB_MAX_IDLE_CONNS}
|
|
BLUEPRINT_DB_MAX_OPEN_CONNS: ${BLUEPRINT_DB_MAX_OPEN_CONNS}
|
|
BLUEPRINT_DB_CONN_MAX_LIFETIME: ${BLUEPRINT_DB_CONN_MAX_LIFETIME}
|
|
LOGGER_LOG_LEVEL: ${LOGGER_LOG_LEVEL}
|
|
LOGGER_FILE_LOG_NAME: ${LOGGER_FILE_LOG_NAME}
|
|
LOGGER_MAX_SIZE: ${LOGGER_MAX_SIZE}
|
|
LOGGER_MAX_BACKUPS: ${LOGGER_MAX_BACKUPS}
|
|
LOGGER_MAX_AGE: ${LOGGER_MAX_AGE}
|
|
LOGGER_COMPRESS: ${LOGGER_COMPRESS}
|
|
depends_on:
|
|
mysql_bp:
|
|
condition: service_healthy
|
|
networks:
|
|
- blueprint
|
|
deploy:
|
|
replicas: 3
|
|
update_config:
|
|
parallelism: 1
|
|
delay: 10s
|
|
restart_policy:
|
|
condition: on-failure
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "http://localhost:${PORT}/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
mysql_bp:
|
|
image: mysql:8.0
|
|
restart: unless-stopped
|
|
environment:
|
|
MYSQL_DATABASE: ${BLUEPRINT_DB_DATABASE}
|
|
MYSQL_ROOT_PASSWORD: ${BLUEPRINT_DB_ROOT_PASSWORD}
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
|
|
ports:
|
|
- "3306:3306"
|
|
volumes:
|
|
- mysql_volume_bp:/var/lib/mysql
|
|
- mysql_backup:/backup
|
|
command: >
|
|
--default-authentication-plugin=mysql_native_password
|
|
--character-set-server=utf8mb4
|
|
--collation-server=utf8mb4_unicode_ci
|
|
--skip-name-resolve
|
|
--explicit_defaults_for_timestamp=1
|
|
--max_connections=1000
|
|
--innodb_buffer_pool_size=256M
|
|
--innodb_log_buffer_size=16M
|
|
--innodb_log_file_size=256M
|
|
--innodb_write_io_threads=8
|
|
--innodb_read_io_threads=8
|
|
--innodb_thread_concurrency=0
|
|
--innodb_flush_log_at_trx_commit=2
|
|
--innodb_flush_method=O_DIRECT
|
|
--innodb_file_per_table=1
|
|
--bind-address=0.0.0.0
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${BLUEPRINT_DB_ROOT_PASSWORD}", "--connect-timeout=5"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 180s
|
|
networks:
|
|
- blueprint
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/conf.d:/etc/nginx/conf.d
|
|
- ./nginx/ssl:/etc/nginx/ssl
|
|
depends_on:
|
|
- app
|
|
networks:
|
|
- blueprint
|
|
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
restart: unless-stopped
|
|
ports:
|
|
- "9090:9090"
|
|
volumes:
|
|
- ./prometheus:/etc/prometheus
|
|
- prometheus_data:/prometheus
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
|
|
- '--web.console.templates=/usr/share/prometheus/consoles'
|
|
networks:
|
|
- blueprint
|
|
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3000:3000"
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
|
|
depends_on:
|
|
- prometheus
|
|
networks:
|
|
- blueprint
|
|
|
|
mysql-backup:
|
|
image: mysql:8.0
|
|
volumes:
|
|
- mysql_backup:/backup
|
|
environment:
|
|
MYSQL_HOST: mysql_bp
|
|
MYSQL_USER: blueprint_user
|
|
MYSQL_PASSWORD: ${BLUEPRINT_DB_PASSWORD}
|
|
MYSQL_DATABASE: ${BLUEPRINT_DB_DATABASE}
|
|
entrypoint: |
|
|
/bin/sh -c '
|
|
while true; do
|
|
mysqldump -h$$MYSQL_HOST -u$$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE > /backup/backup-$$(date +%Y%m%d-%H%M%S).sql;
|
|
find /backup -type f -mtime +7 -delete;
|
|
sleep 86400;
|
|
done
|
|
'
|
|
networks:
|
|
- blueprint
|
|
|
|
networks:
|
|
blueprint:
|
|
|
|
volumes:
|
|
mysql_volume_bp:
|
|
mysql_backup:
|
|
prometheus_data:
|
|
grafana_data: |