Skip to content

Commit 936391d

Browse files
authored
Merge pull request #2 from Apollo-Reborn/migrate-statsd-scripts
Move migrate and statsd container commands into scripts
2 parents 63570eb + 6bda99b commit 936391d

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

docker-compose.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ services:
3636
POSTGRES_USER: apollo
3737
POSTGRES_PASSWORD: apollo
3838
POSTGRES_DB: apollo
39-
ports:
40-
- "5432:5432"
4139
volumes:
4240
- pgdata:/var/lib/postgresql/data
4341
healthcheck:
@@ -59,17 +57,13 @@ services:
5957
SERVER_RESET_QUERY: DISCARD ALL
6058
AUTH_TYPE: scram-sha-256
6159
ADMIN_USERS: postgres,apollo
62-
ports:
63-
- "6432:6432"
6460
depends_on:
6561
postgres:
6662
condition: service_healthy
6763

6864
redis-queue:
6965
image: redis:7-alpine
7066
command: ["redis-server", "--maxmemory-policy", "noeviction"]
71-
ports:
72-
- "6379:6379"
7367
healthcheck:
7468
test: ["CMD", "redis-cli", "ping"]
7569
interval: 5s
@@ -79,8 +73,6 @@ services:
7973
redis-locks:
8074
image: redis:7-alpine
8175
command: ["redis-server", "--maxmemory-policy", "noeviction"]
82-
ports:
83-
- "6380:6379"
8476
healthcheck:
8577
test: ["CMD", "redis-cli", "ping"]
8678
interval: 5s
@@ -91,7 +83,9 @@ services:
9183
# unreachable, but it doesn't care what's actually on the other end.
9284
statsd:
9385
image: alpine:3.19
94-
command: ["sh", "-c", "apk add --no-cache socat >/dev/null && exec socat -u udp-recv:8125 stdout"]
86+
entrypoint: /statsd.sh
87+
volumes:
88+
- ./docker/statsd.sh:/statsd.sh:ro
9589
expose:
9690
- "8125/udp"
9791

@@ -103,18 +97,10 @@ services:
10397
image: postgres:14-alpine
10498
environment:
10599
PGPASSWORD: apollo
106-
entrypoint: ["sh", "-c"]
107-
command:
108-
- |
109-
set -e
110-
if psql -h postgres -U apollo -d apollo -tAc "SELECT to_regclass('public.accounts')" | grep -q accounts; then
111-
echo "schema already loaded, skipping"
112-
else
113-
psql -h postgres -U apollo -d apollo -v ON_ERROR_STOP=1 -f /schema.sql
114-
echo "schema loaded"
115-
fi
100+
entrypoint: /migrate.sh
116101
volumes:
117102
- ./docs/schema.sql:/schema.sql:ro
103+
- ./docker/migrate.sh:/migrate.sh:ro
118104
depends_on:
119105
postgres:
120106
condition: service_healthy

docker/migrate.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -e
3+
if psql -h postgres -U apollo -d apollo -tAc "SELECT to_regclass('public.accounts')" | grep -q accounts; then
4+
echo "schema already loaded, skipping"
5+
else
6+
psql -h postgres -U apollo -d apollo -v ON_ERROR_STOP=1 -f /schema.sql
7+
echo "schema loaded"
8+
fi

docker/statsd.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
# No-op UDP sink for statsd. The Datadog client crashes if STATSD_URL is
3+
# unreachable, but it doesn't care what's actually on the other end.
4+
set -e
5+
apk add --no-cache socat >/dev/null
6+
exec socat -u udp-recv:8125 stdout

0 commit comments

Comments
 (0)