-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yml
77 lines (72 loc) · 1.7 KB
/
compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
version: '3.8'
services:
short-url:
build:
context: .
dockerfile: Dockerfile
container_name: short-url
restart: always
environment:
MYSQL_DSN: user:password@tcp(mysql:3306)/db?charset=utf8mb4&parseTime=True&loc=Local
REDIS_ADDR: redis:6379
ports:
- 8080:8080
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
mysql:
image: mysql:8.0
container_name: mysql
restart: always
environment:
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-ppassword"]
interval: 3s
timeout: 15s
retries: 5
start_period: 10s
volumes:
- mysql_data:/var/lib/mysql
redis:
image: redis:7.2
container_name: redis
restart: always
ports:
- 6379:6379
healthcheck:
test: ["CMD", "redis-cli" ,"ping"]
interval: 3s
timeout: 15s
retries: 5
start_period: 10s
volumes:
- ./configs/redis.conf:/usr/local/etc/redis/redis.conf
- redis_data:/var/data/redis
# only run migration once
dbmate:
image: amacneil/dbmate:2.8.0
container_name: dbmate
restart: no
environment:
DBMATE_MIGRATIONS_DIR: /db/migrations
DBMATE_SCHEMA_FILE: /db/schema.sql
DATABASE_URL: mysql://user:password@mysql:3306/db
depends_on:
mysql:
condition: service_healthy
volumes:
- ./assets/db/migrations:/db/migrations
command: ["--wait", "up"]
volumes:
mysql_data:
external: false
redis_data:
external: false