working remote image

parent f2c43850
version: "3.8"
services:
postgres:
build:
context: ./postgres
dockerfile: Dockerfile
# Use the new custom image from Docker Hub
image: salmamohammedhamedmustafa/postgres:latest
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
......
......@@ -17,7 +17,7 @@ COPY . .
# Make the script executable
RUN chmod +x wait-for-postgres.sh
# Use the script as the entrypoint
# Use the full path for the entrypoint
ENTRYPOINT ["/app/wait-for-postgres.sh"]
# This is your application's original startup command
......
#!/bin/bash
# wait-for-postgres.sh
set -e
host="postgres"
port="5432"
dbname="${POSTGRES_DB}"
user="${POSTGRES_USER}"
db="${POSTGRES_DB}"
password="${POSTGRES_PASSWORD}"
echo "Waiting for PostgreSQL..."
echo "Waiting for PostgreSQL database to be ready..."
# Wait for the database server to be available
until PGPASSWORD="$password" pg_isready -h "$host" -U "$user"; do
echo "PostgreSQL server is unavailable - sleeping"
sleep 1
done
until PGPASSWORD=$password pg_isready -h $host -p $port -U $user; do
echo "PostgreSQL is unavailable - sleeping"
# Wait for the specific database to be available
until PGPASSWORD="$password" psql -h "$host" -U "$user" -d "$db" -c '\q'; do
echo "Database '$db' is not yet available - sleeping"
sleep 1
done
echo "PostgreSQL is up - executing command"
echo "PostgreSQL database is up and ready - executing command"
exec "$@"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment