ok this seems to work

This commit is contained in:
counterweight 2025-02-14 20:03:28 +01:00
parent e725dce831
commit 15ffabebf3
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 54 additions and 46 deletions

26
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,26 @@
#!/bin/bash
# Start PostgreSQL service
service postgresql start
# Wait for PostgreSQL to be ready
until su - postgres -c "pg_isready"; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
# Create the database and user if they don't exist
su - postgres -c "psql -tc \"SELECT 1 FROM pg_roles WHERE rolname = '$POSTGRES_USER';\"" | grep -q 1 || \
su - postgres -c "psql -c \"CREATE USER $POSTGRES_USER WITH ENCRYPTED PASSWORD '$POSTGRES_PASSWORD';\""
su - postgres -c "psql -tc \"SELECT 1 FROM pg_database WHERE datname = '$POSTGRES_DB';\"" | grep -q 1 || \
su - postgres -c "psql -c \"CREATE DATABASE $POSTGRES_DB OWNER $POSTGRES_USER;\""
# Start Caddy
caddy run --config /etc/caddy/Caddyfile &
# Start Express app
npm start
# Keep container running
wait