-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-compose.yaml
155 lines (148 loc) · 5.8 KB
/
docker-compose.yaml
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
version: '3.8'
services:
django:
build:
context: .
dockerfile: ./build/local/Dockerfile
image: beer_analytics_local
container_name: beer_analytics_django
restart: on-failure
environment:
DJANGO_SETTINGS_MODULE: config.settings_dev
DATABASE_HOST: beer_analytics_db
DATABASE_NAME: beer_analytics
DATABASE_USER: root
DATABASE_PASSWORD: root
APP_URL: ${APP_URL}
SECRET_KEY: ${SECRET_KEY}
RAW_DATA_DIR: ${RAW_DATA_DIR}
CACHE_DIR: ${CACHE_DIR}
ALLOWED_HOSTS: ${ALLOWED_HOSTS}
LOG_FILE: ${LOG_FILE}
LOG_LEVEL: ${LOG_LEVEL}
WEB_ANALYTICS_ROOT_URL: '/wa/'
WEB_ANALYTICS_SITE_ID: 0
GOOGLE_API_CLIENT_CONFIG_FILE: ${GOOGLE_API_CLIENT_CONFIG_FILE}
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD}
OPENAI_API_KEY: ${OPENAI_API_KEY}
volumes:
- .:/app:z
- beer_analytics_es_certs:/usr/share/elasticsearch/config/certs
ports:
- "8000:8000"
depends_on:
- db
db:
image: mariadb:11.0
container_name: beer_analytics_db
environment:
MARIADB_DATABASE: beer_analytics
MARIADB_USER: beer_analytics
MARIADB_PASSWORD: beer_analytics
MARIADB_ROOT_PASSWORD: 'root'
MARIADB_AUTO_UPGRADE: 1
ports:
- "3308:3306"
volumes:
- 'beer_analytics_db:/var/lib/mysql'
elasticsearch_setup:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
container_name: beer_analytics_es_setup
volumes:
- beer_analytics_es_certs:/usr/share/elasticsearch/config/certs
user: "0"
command: >
bash -c '
if [ x${ELASTIC_PASSWORD} == x ]; then
echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
exit 1;
elif [ x${KIBANA_PASSWORD} == x ]; then
echo "Set the KIBANA_PASSWORD environment variable in the .env file";
exit 1;
fi;
if [ ! -f config/certs/ca.zip ]; then
echo "Creating CA";
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip;
unzip config/certs/ca.zip -d config/certs;
fi;
if [ ! -f config/certs/certs.zip ]; then
echo "Creating certs";
echo -ne \
"instances:\n"\
" - name: es\n"\
" dns:\n"\
" - elasticsearch\n"\
" - localhost\n"\
" ip:\n"\
" - 127.0.0.1\n"\
" - name: kibana\n"\
" dns:\n"\
" - kibana\n"\
" - localhost\n"\
" ip:\n"\
" - 127.0.0.1\n"\
> config/certs/instances.yml;
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key;
unzip config/certs/certs.zip -d config/certs;
fi;
echo "Setting file permissions"
chown -R root:root config/certs;
find . -type d -exec chmod 750 \{\} \;;
find . -type f -exec chmod 640 \{\} \;;
echo "Waiting for Elasticsearch availability";
until curl -s --cacert config/certs/ca/ca.crt https://elasticsearch:9200 | grep -q "missing authentication credentials"; do sleep 30; done;
echo "Setting kibana_system password";
until curl -s -X POST --cacert config/certs/ca/ca.crt -u "elastic:${ELASTIC_PASSWORD}" -H "Content-Type: application/json" https://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done;
echo "All done!";
'
healthcheck:
test: [ "CMD-SHELL", "[ -f config/certs/es/es.crt ]" ]
interval: 1s
timeout: 5s
retries: 120
elasticsearch:
depends_on:
elasticsearch_setup:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
container_name: beer_analytics_es
labels:
co.elastic.logs/module: elasticsearch
volumes:
- beer_analytics_es_certs:/usr/share/elasticsearch/config/certs
- beer_analytics_es_esdata:/usr/share/elasticsearch/data
ports:
- ${ES_PORT}:9200
environment:
- node.name=es
- cluster.name=${CLUSTER_NAME}
- discovery.type=single-node
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
- bootstrap.memory_lock=true
- http.publish_host=elasticsearch
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=false
- xpack.security.transport.ssl.enabled=false
- xpack.license.self_generated.type=${LICENSE}
mem_limit: ${ES_MEM_LIMIT}
ulimits:
memlock:
soft: -1
hard: -1
healthcheck:
test:
[
"CMD-SHELL",
"curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'",
]
interval: 10s
timeout: 10s
retries: 120
volumes:
beer_analytics_db:
beer_analytics_es_certs:
beer_analytics_es_esdata:
networks:
default:
name: beer_analytics
external: false