feat(compose): add dev mysql service, init scripts, profile-gate bots
This commit is contained in:
parent
7011c6bada
commit
57d4a8a68d
@ -4,12 +4,16 @@ services:
|
||||
context: .
|
||||
dockerfile: docker/telegram/Dockerfile
|
||||
image: "${CM_IMAGE_PREFIX:-local}/cm-telegram:${DOCKER_IMAGE_TAG:-dev}"
|
||||
profiles: ["bots"]
|
||||
|
||||
api-server:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/api/Dockerfile
|
||||
image: "${CM_IMAGE_PREFIX:-local}/cm-api:${DOCKER_IMAGE_TAG:-dev}"
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
|
||||
web-view:
|
||||
build:
|
||||
@ -27,3 +31,32 @@ services:
|
||||
CM_TRANSFER_MAX_THREADS: "1"
|
||||
mem_limit: 2g
|
||||
cpus: 2
|
||||
profiles: ["bots"]
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: ${CM_DEPLOY_NAME:-cm}-mysql
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-devroot}
|
||||
MYSQL_DATABASE: ${DB_NAME}
|
||||
MYSQL_USER: ${DB_USER}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
ports:
|
||||
- "127.0.0.1:3306:3306"
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
- ./docker/mysql/init.d:/docker-entrypoint-initdb.d:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-devroot}"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 12
|
||||
networks:
|
||||
- bot-network
|
||||
|
||||
volumes:
|
||||
mysql-data:
|
||||
name: ${CM_DEPLOY_NAME:-cm}-mysql-data
|
||||
|
||||
17
docker/mysql/init.d/01-schema.sql
Normal file
17
docker/mysql/init.d/01-schema.sql
Normal file
@ -0,0 +1,17 @@
|
||||
-- Schema for the CM bot dev DB. Mounted at
|
||||
-- /docker-entrypoint-initdb.d/01-schema.sql in the mysql:8.0 container;
|
||||
-- runs once on first volume initialization.
|
||||
CREATE TABLE IF NOT EXISTS acc (
|
||||
username VARCHAR(64) PRIMARY KEY,
|
||||
password VARCHAR(128) NOT NULL,
|
||||
status VARCHAR(32) DEFAULT '',
|
||||
link VARCHAR(512) DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user (
|
||||
f_username VARCHAR(64) PRIMARY KEY,
|
||||
f_password VARCHAR(128) NOT NULL,
|
||||
t_username VARCHAR(64) NOT NULL,
|
||||
t_password VARCHAR(128) NOT NULL,
|
||||
last_update_time TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
8
docker/mysql/init.d/02-seed.sql
Normal file
8
docker/mysql/init.d/02-seed.sql
Normal file
@ -0,0 +1,8 @@
|
||||
-- Dev-only seed. Four acc rows matching CM_PREFIX_PATTERN=13c so
|
||||
-- get_next_username has something to anchor on. Passwords are placeholder
|
||||
-- strings — never real cm99.net credentials.
|
||||
INSERT INTO acc (username, password, status, link) VALUES
|
||||
('13c1000', 'seedpass', '', ''),
|
||||
('13c1001', 'seedpass', '', ''),
|
||||
('13c1002', 'seedpass', '', ''),
|
||||
('13c1003', 'seedpass', '', '');
|
||||
Loading…
x
Reference in New Issue
Block a user