I’d like to run this “amend_user.sql” script in the database as per below sequence. I just dont know how to do this using docker compose with yaml file. Please advise.
- Download image & create postgres instance
- Run the flyway job
- Execute “amend_user.sql” in postgres database
In the below example, this script runs as soon as the service starts whereas i would like it to run at the end or after step 2.
version: '3.8' services:
db:
container_name: postgresDB
image: postgres:15.1
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
ports:
- '5432:5432'
volumes:
- postgres:/var/lib/postgresql/data
- ./scripts/amend_user.sql:/docker-entrypoint-initdb.d/amend_user.sql
build:
context: .
dockerfile: dockerfile-db
flyway_admin:
image: redgate/flyway:6.6.1
environment:
- FLYWAY_USER=postgres
- FLYWAY_PASSWORD=password
- FLYWAY_URL=jdbc:postgresql://db:5432/postgres
- FLYWAY_LOCATIONS=filesystem:/flyway/admin/versions
command: -connectRetries=60 check
volumes:
- ./admin/:/flyway/sql/admin
depends_on:
- db
volumes:
postgres: