-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
124 lines (116 loc) · 3.48 KB
/
docker-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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
services:
development_setup:
build:
context: .
dockerfile: Dockerfile
target: development_setup
depends_on:
postgres:
condition: service_healthy
es01:
condition: service_healthy
env_file:
- .env
command: npm install
volumes:
- .:/app
profiles:
- development
blog-api:
build:
context: .
dockerfile: Dockerfile
target: development
depends_on:
development_setup:
condition: service_completed_successfully
ports:
- ${PORT}:${PORT}
working_dir: /app
command: sh -c "export POSTGRES_HOST=${POSTGRES_HOST} && npm run typeorm:migration:run && npm run typeorm:seed && npm run start:dev"
volumes:
- .:/app
profiles:
- development
postgres:
image: postgres:16
ports:
- 5432:5432
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres-data-dev:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER}']
interval: 10s
timeout: 5s
retries: 5
profiles:
- development
es_setup:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
command: >
bash -c '
if [ x${ELASTIC_USER_PASSWORD} == x ]; then
echo "Set the ELASTIC_USER_PASSWORD environment variable in the .env file";
exit 1;
elif [ x${KIBANA_SYSTEM_USER_PASSWORD} == x ]; then
echo "Set the KIBANA_SYSTEM_USER_PASSWORD environment variable in the .env file";
exit 1;
fi;
until curl -s -u elastic:${ELASTIC_USER_PASSWORD} -XGET "http://es01:9200/_cluster/health?wait_for_status=yellow&timeout=30s"; do
echo "Waiting for Elasticsearch to start up...";
sleep 5;
done;
echo "Elasticsearch is up and running!";
echo "Setting passwords...";
curl -s -u elastic:${ELASTIC_USER_PASSWORD} -X POST "http://es01:9200/_security/user/kibana_system/_password" -H "Content-Type: application/json" -d"{\"password\":\"${KIBANA_SYSTEM_USER_PASSWORD}\"}";
echo "\nAll Done!";
'
profiles:
- development
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
depends_on:
- es_setup
ports:
- ${ELASTIC_SEARCH_PORT}:9200
volumes:
- esdata01-dev:/usr/share/elasticsearch/data
environment:
- node.name=es01
- discovery.type=single-node
- xpack.security.enabled=true
- ELASTIC_PASSWORD=${ELASTIC_USER_PASSWORD}
healthcheck:
test:
[
'CMD-SHELL',
'curl -s -u elastic:${ELASTIC_USER_PASSWORD} http://es01:9200/_cluster/health?wait_for_status=yellow&timeout=30s',
]
interval: 10s
timeout: 5s
retries: 5
profiles:
- development
kibana:
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
depends_on:
- es_setup
- es01
ports:
- ${KIBANA_PORT}:5601
environment:
- ELASTICSEARCH_HOSTS=http://es01:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_SYSTEM_USER_PASSWORD}
volumes:
- kibanadata-dev:/usr/share/kibana/data
profiles:
- development
volumes:
postgres-data-dev:
esdata01-dev:
kibanadata-dev: