services: database: # Use the official Postgres image from Docker Hub image: postgres:15-alpine # Restart the container if it fails restart: always # Use a volume to persist the database data volumes: - ${POSTGRES_VOLUME_NAME}:/var/lib/postgresql/data # Load environment variables from the .env file env_file: - .env semaphore: # Use the official Semaphore image image: semaphoreui/semaphore:v2.9.2 # The application depends on the database service depends_on: - database # Restart the container if it fails restart: always # Map the host port to the container's fixed port 3000 ports: - "${SEMAPHORE_PORT_HOST}:3000" # Load environment variables from the .env file env_file: - .env # The command to run the Semaphore container, which will wait for the database command: > sh -c 'while ! pg_isready -h database -p 5432 > /dev/null 2> /dev/null; do sleep 1; done && /usr/bin/semaphore --config /etc/semaphore/semaphore.json' volumes: # Define a named volume for the persistent database data ${POSTGRES_VOLUME_NAME}: