ok this seems to work
This commit is contained in:
parent
e725dce831
commit
15ffabebf3
6 changed files with 54 additions and 46 deletions
26
docker-entrypoint.sh
Normal file
26
docker-entrypoint.sh
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue