Add Liquibase with docker-compose

So I am trying to integrate my liquibase with an already existing docker image of Postgres. There are already images of frontend and backend in the docker-compose.yml file and I have my changelog scripts too but I am not sure how to proceed with integrating the liquibase changelog in the already existing docker-changelog.yml.
Any cues on how to proceed?

This is my example docker-compose.yml file:

version: '3'
services:
    PostgreSQL:
        # service details
    Liquibase:
        # service details
    Backend:
        # service details
    Frontend:
        # service details

My Postgres changelog has database updation scripts and everything, I just don’t know how to proceed with adding those in the docker-compose file to run and create everything with the command:

docker-compose up -d

So I got a way to handle the liquibase update command. Here’s what I used as my Liquibase service, if it helps anyone:

Liquibase:
    # Image to be pulled from Docker Hub
    image: liquibase/liquibase:4.9.1
    # Name of the container
    container_name: Liquibase_container
    # Setting depends_on to PostgreSQL container to wait till the service is ready to accept connections
    depends_on:
      PostgreSQL:
        condition: service_healthy
    # Volume to add the liquibase collection of scripts
    volumes:
      - ./database/sql/liquibase/changeLog/:/liquibase/changelog/
    # Command to run the liquibase update service
    command: --defaults-file=/liquibase/changelog/liquibase.properties update

I moved my changeLog files to a volume inside the container named liquibase/changelog and then used the command to run update.

1 Like