Skip to content

Commit

Permalink
fix: avoid hardcoding the database hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Dec 27, 2024
1 parent 45d0edd commit cd936bf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mods/apiserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ RUN npm install -g prisma@6.1.0 npm@latest

USER appuser

# TODO: Fix hardcode host for db
CMD sh -c "dockerize -wait tcp://postgres:5432 -timeout 30s && \
# Extract database host and port from DATABASE_URL environment variable
CMD DB_HOST=$(echo $DATABASE_URL | sed -n 's/.*@\([^:/]*\)[:/].*/\1/p') && \
DB_PORT=$(echo $DATABASE_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p') && \
if [ -z "$DB_PORT" ]; then DB_PORT=5432; fi && \
dockerize -wait tcp://${DB_HOST}:${DB_PORT} -timeout 30s && \
cd /service/core && \
npx prisma migrate deploy && \
cd /service/identity && \
npx prisma migrate deploy && \
node /usr/local/lib/node_modules/@fonoster/apiserver/dist/core/seed.js && \
node /usr/local/lib/node_modules/@fonoster/apiserver/dist/index.js"
node /usr/local/lib/node_modules/@fonoster/apiserver/dist/index.js

0 comments on commit cd936bf

Please sign in to comment.