-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.dev.yaml
More file actions
80 lines (73 loc) · 2.39 KB
/
compose.dev.yaml
File metadata and controls
80 lines (73 loc) · 2.39 KB
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
services:
postgres:
image: postgres:15
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- postgres_data_external:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 10
command: ["postgres", "-c", "listen_addresses=*"]
db-init:
image: postgres:15
depends_on:
postgres:
condition: service_healthy
environment:
PGHOST: postgres
PGUSER: ${POSTGRES_USER}
PGPASSWORD: ${POSTGRES_PASSWORD}
PGDATABASE: postgres
volumes:
- ./edaphobase.sql:/tmp/edaphobase.sql:ro
entrypoint: /bin/bash
command:
- -c
- |
set -euo pipefail
apt-get update && apt-get install -y --no-install-recommends wget ca-certificates
echo "Dropping and recreating database rdi..."
psql -c "DROP DATABASE IF EXISTS rdi;"
psql -c "CREATE DATABASE rdi;"
echo "Attempting to download latest Edaphobase dump..."
if wget -q -O /tmp/downloaded_edaphobase.sql https://repo.edaphobase.org/rep/dumps/FAIRagro.sql; then
echo "Importing downloaded dump..."
PGDATABASE=rdi psql < /tmp/downloaded_edaphobase.sql
elif [ -f /tmp/edaphobase.sql ]; then
echo "Download failed. Importing local edaphobase.sql fallback..."
PGDATABASE=rdi psql < /tmp/edaphobase.sql
else
echo "Error: Could not download dump and no local fallback found."
exit 1
fi
echo "Database initialization complete."
sql_to_arc:
image: sql_to_arc:latest
build:
context: ..
dockerfile: docker/Dockerfile.sql_to_arc
depends_on:
db-init:
condition: service_completed_successfully
environment:
SQL_TO_ARC_CONNECTION_STRING: ${CONNECTION_STRING}
SQL_TO_ARC_CLIENT_KEY_DATA: ${CLIENT_KEY}
tmpfs:
- /run/secrets:mode=1777
volumes:
- ./config.dev.yaml:/etc/sql_to_arc/config.yaml:ro
- ./client.crt:/etc/sql_to_arc/client.crt:ro
command: >
sh -c "printf '%s' \"$$SQL_TO_ARC_CLIENT_KEY_DATA\" > /run/secrets/client.key &&
/middleware/sql_to_arc/sql_to_arc -c /etc/sql_to_arc/config.yaml"
restart: no
volumes:
postgres_data_external: