andreoss
andreoss

Reputation: 1800

How to build Docker image for Testcontainers from Liquibase changelogs?

I have liquibase changelogs inside my project. I want to build a Docker image from them in order to use for integration tests with Testcontainers. How should I do it?

Upvotes: 2

Views: 855

Answers (1)

rieckpil
rieckpil

Reputation: 12021

You can achieve this with the following:

  1. Start a local empty database (e.g. use a Docker container to start PostgreSQL)
  2. Run your application or the Liquibase Maven Plugin against the local database to apply the changeset
  3. Create a dump of your local database
  4. Write your own Dockerfile while extending the Docker image from your database vendor and apply the database dump on database startup
  5. Built the Docker image locally and (if required) push it to your Docker registry
  6. Use Testcontainers and reference to this Docker image

Nevertheless, you would have to update your custom Docker image every time you add a new Liquibase changelog. Why not let them run with your integration test and use a raw database?

Upvotes: 2

Related Questions