Skip to content

Commit aa8fe75

Browse files
committed
Postgrest connection fix
1 parent e22c30a commit aa8fe75

4 files changed

Lines changed: 38 additions & 8 deletions

File tree

docker-compose.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ services:
4040
platform: linux/x86_64
4141
depends_on:
4242
- postgres
43+
env_file:
44+
- .env
4345
volumes:
4446
- ./server:/app/server:delegated
4547
- ./plugins:/app/plugins
@@ -57,7 +59,7 @@ services:
5759
container_name: postgrest
5860
image: postgrest/postgrest:v12.0.2
5961
ports:
60-
- "3001:3000"
62+
- "3002:3002"
6163
env_file:
6264
- .env
6365
depends_on:

docker/ce-entrypoint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ if [ -f "./.env" ]; then
1515
declare $(grep -v '^#' ./.env | xargs)
1616
fi
1717

18-
export NODE_OPTIONS="--max-old-space-size=4096 --experimental-global-webcrypto"
19-
2018
if [ -z "$DATABASE_URL" ]; then
2119
./server/scripts/wait-for-it.sh $PG_HOST:${PG_PORT:-5432} --strict --timeout=300 -- $SETUP_CMD
2220
else
@@ -30,6 +28,4 @@ else
3028
./server/scripts/wait-for-it.sh "$PG_HOST:$PG_PORT" --strict --timeout=300 -- $SETUP_CMD
3129
fi
3230

33-
34-
npm --prefix server run start:dev
35-
31+
exec "$@"

docker/server.Dockerfile.dev

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ COPY ./package.json ./package.json
2727

2828
# install app dependencies
2929
COPY ./server/package.json ./server/package-lock.json ./server/
30-
COPY ./docker/ce-entrypoint.sh ./docker/ce-entrypoint.sh
3130
RUN npm --prefix server install
3231
COPY ./server/ ./server/
3332

34-
ENTRYPOINT ["./docker/ce-entrypoint.sh"]
33+
ENTRYPOINT ["./server/ce-entrypoint.sh"]

server/ce-entrypoint.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ -f "./.env" ]; then
5+
export $(grep -v '^#' ./.env | xargs -d '\n') || true
6+
fi
7+
8+
if [ -d "./server/dist" ]; then
9+
SETUP_CMD='npm run db:setup:prod'
10+
else
11+
SETUP_CMD='npm run db:setup'
12+
fi
13+
14+
if [ -f "./.env" ]; then
15+
declare $(grep -v '^#' ./.env | xargs)
16+
fi
17+
18+
export NODE_OPTIONS="--max-old-space-size=4096 --experimental-global-webcrypto"
19+
20+
if [ -z "$DATABASE_URL" ]; then
21+
./server/scripts/wait-for-it.sh $PG_HOST:${PG_PORT:-5432} --strict --timeout=300 -- $SETUP_CMD
22+
else
23+
PG_HOST=$(echo "$DATABASE_URL" | awk -F'[/:@?]' '{print $6}')
24+
PG_PORT=$(echo "$DATABASE_URL" | awk -F'[/:@?]' '{print $7}')
25+
26+
if [ -z "$DATABASE_PORT" ]; then
27+
DATABASE_PORT="5432"
28+
fi
29+
30+
./server/scripts/wait-for-it.sh "$PG_HOST:$PG_PORT" --strict --timeout=300 -- $SETUP_CMD
31+
fi
32+
33+
npm --prefix server run start:dev

0 commit comments

Comments
 (0)