forked from CenterForOpenScience/SHARE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
228 lines (212 loc) · 7.3 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Taken from https://github.com/CenterForOpenScience/osf.io/pull/6364/files#diff-4e5e90c6228fd48698d074241c2ba760R1
# Install the Docker Client
# - https://www.docker.com/products/docker-desktop
version: '3.4'
volumes:
postgres_data_vol:
external: false
elastic8_data_vol:
external: false
elastic8_cert_vol:
external: false
rabbitmq_vol:
external: false
share_vol:
external: false
share_dist_vol:
external: false
share_requirements_vol:
external: false
services:
####################
# Backend Services #
####################
elastic8_setup:
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0
volumes:
- elastic8_cert_vol:/usr/share/elasticsearch/config/certs
user: "0"
environment:
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-secretsecret}
KIBANA_PASSWORD: ${KIBANA_PASSWORD:-kibanakibana}
command: >
bash -c '
if [ x$${ELASTIC_PASSWORD} == x ]; then
echo "Set the ELASTIC_PASSWORD environment variable";
exit 1;
elif [ x$${KIBANA_PASSWORD} == x ]; then
echo "Set the KIBANA_PASSWORD environment variable";
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: singlenode\n"\
" dns:\n"\
" - elastic8\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://elastic8:9200 | grep -q "missing authentication credentials"; do sleep 1; 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://elastic8:9200/_security/user/kibana_system/_password -d "{\"password\":\"$${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 1; done;
echo "All done!";
'
healthcheck:
test: ["CMD-SHELL", "[ -f config/certs/singlenode/singlenode.crt ]"]
interval: 1s
timeout: 5s
retries: 120
elastic8:
depends_on:
elastic8_setup:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0
ports:
- 9208:9200
volumes:
- elastic8_data_vol:/usr/share/elasticsearch/data
- elastic8_cert_vol:/usr/share/elasticsearch/config/certs/
environment:
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-secretsecret}
- node.name=singlenode
- cluster.initial_master_nodes=singlenode
- ES_JAVA_OPTS=-Xms512m -Xmx512m # raise memory limits a lil bit
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true
- xpack.security.http.ssl.key=certs/singlenode/singlenode.key
- xpack.security.http.ssl.certificate=certs/singlenode/singlenode.crt
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.key=certs/singlenode/singlenode.key
- xpack.security.transport.ssl.certificate=certs/singlenode/singlenode.crt
- xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt
- xpack.security.transport.ssl.verification_mode=certificate
stdin_open: true
rabbitmq:
image: rabbitmq:management
ports:
- 5673:5672
- 15673:15672
volumes:
- rabbitmq_vol:/var/lib/rabbitmq
stdin_open: true
postgres:
image: postgres:10
command:
- /bin/bash
- -c
- echo "$$POSTGRES_INITDB" > /docker-entrypoint-initdb.d/commands.sh &&
chmod +x /docker-entrypoint-initdb.d/commands.sh &&
/docker-entrypoint.sh postgres
ports:
- 5433:5432
environment:
POSTGRES_DB: share
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB: |
sed -i -e 's/max_connections.*/max_connections = 5000/' /var/lib/postgresql/data/postgresql.conf
sed -i -e 's/#log_min_duration_statement = .*/log_min_duration_statement = 0/' /var/lib/postgresql/data/postgresql.conf
volumes:
- "${POSTGRES_DATA_VOL:-postgres_data_vol}:/var/lib/postgresql/data/"
stdin_open: true
##################
# SHARE software #
##################
requirements:
image: quay.io/centerforopenscience/share:develop
command:
- /bin/bash
- -c
- apt-get update &&
apt-get install -y gcc &&
pip install -r requirements.txt -r dev-requirements.txt &&
(python3 -m compileall /usr/local/lib/python3.10 || true) &&
rm -Rf /python3.10/* &&
apt-get remove -y gcc &&
cp -Rf -p /usr/local/lib/python3.10 / &&
python3 setup.py develop
restart: 'no'
volumes:
- ./:/code:cached
- share_requirements_vol:/python3.10
frontend:
image: quay.io/centerforopenscience/share-web:develop-local
command: yarn start
ports:
- 4204:4200
volumes:
- share_dist_vol:/code/dist
stdin_open: true
worker:
image: quay.io/centerforopenscience/share:develop
command: /usr/local/bin/celery --app project worker --uid daemon -l INFO
depends_on:
- postgres
- rabbitmq
- web
- elastic8
- indexer
volumes:
- ./:/code:cached
- share_requirements_vol:/usr/local/lib/python3.10
- elastic8_cert_vol:/elastic8_certs
env_file:
- .docker-compose.env
environment:
ELASTICSEARCH8_SECRET: ${ELASTIC_PASSWORD:-secretsecret}
ELASTICSEARCH8_CERT_PATH: /elastic8_certs/ca/ca.crt
stdin_open: true
web:
image: quay.io/centerforopenscience/share:develop
command: python manage.py runserver 0.0.0.0:8000
ports:
- 8003:8000
depends_on:
- postgres
- rabbitmq
- elastic8
- frontend
volumes:
- ./:/code:cached
- share_requirements_vol:/usr/local/lib/python3.10
- elastic8_cert_vol:/elastic8_certs
env_file:
- .docker-compose.env
environment:
ELASTICSEARCH8_SECRET: ${ELASTIC_PASSWORD:-secretsecret}
ELASTICSEARCH8_CERT_PATH: /elastic8_certs/ca/ca.crt
stdin_open: true
indexer:
image: quay.io/centerforopenscience/share:develop
command: sharectl search daemon
depends_on:
- postgres
- rabbitmq
- elastic8
volumes:
- ./:/code:cached
- share_requirements_vol:/usr/local/lib/python3.10
- elastic8_cert_vol:/elastic8_certs
env_file:
- .docker-compose.env
environment:
ELASTICSEARCH8_SECRET: ${ELASTIC_PASSWORD:-secretsecret}
ELASTICSEARCH8_CERT_PATH: /elastic8_certs/ca/ca.crt
restart: unless-stopped
stdin_open: true