Sign inSign up

kilna/liquibase-sqlite

By kilna

Updated over 7 years ago

Lightweight docker for applying Liquibase changes against SQLite databases

Image
1

2.1K

kilna/liquibase-sqlite repository overview

liquibase-sqlite-docker

A lightweight Docker for running Liquibase with SQLite databases

DockerHub: liquibase-sqlite - GitHub: liquibase-sqlite-docker

Usage

Using your own derived Dockerfile

You can use this image by creating your own Dockerfile which inherits using a FROM line:

FROM kilna/liquibase-sqlite
ENV LIQUIBASE_DATABASE=dbname.db
COPY changelog.xml /workspace
COPY dbname.db /workspace

Make sure to create an appropriate changelog.xml, and a SQLite 3 database names dbname.db in the same directory as your Dockerfile.

Then you can build your derived Dockerfile to an image tagged 'changelog-image':

$ docker build --tag changelog-image .

Any time you make changes to the example project, you'll need to re-run the docker build command above, or you can using docker volumes as described below to sync local filesystem changes into the container. To run liquibase using the new image you can:

$ docker run changelog-image liquibase updateTestingRollback

Since the working directory within the container is /workspace, and since the entrypoint generates a a liquibase.properties file using the provided environment variables, it will know to look for changelog.xml by default and apply the change. See the environment variables below to change this behavior.

Using the image directly with a mounted docker volume

If you'd like to apply a changelog to a SQLite database without deriving your own container, run the contiainer appropriate to your database like so... where /local/path/to/changelog/ is the directory where a valid changelog.xml exists:

$ docker run -e -e LIQUIBASE_DATABASE=dbname.db -v /local/path/to/changelog/:/workspace/ \
    kilna/liquibase-sqlite  liquibase updateTestingRollback

Environment Variables and liquibase.properties

This docker image has a working Liquibase executable in the path, and an entrypoint which auto-generates a liquibase.properties file.

In order to create the liquibase.properties file, it uses the follow environment variables when the image is started with 'docker run':

Environment VariablePurposeDefault
LIQUIBASE_DATABASEDatabase filenameliquibase
LIQUIBASE_CHANGELOGDefault changelog filename to usechangelog.xml
LIQUIBASE_LOGLEVELLog level as defined by Liquibase
Valid values: debug, info, warning, severe, off
info
LIQUIBASE_CLASSPATHJDBC driver filename/opt/jdbc/sqlite-jdbc.jar
LIQUIBASE_DRIVERJDBC object pathorg.sqlite.JDBC
LIQUIBASE_URLJDBC URL for connectionjdbc:sqlite:${DATABASE}
LIQUIBASE_DEBUGIf set to 'yes', when docker run is executed, will show the values of all LIQUIBASE_* environment variables and describes any substitutions performed on liquibase.propertiesunset

The generated liquibase.properties file is loaded into the default working dir /workspace (which is also shared as a docker volume). The /workspace/liquibase.properties file will have any variables substituted each time a 'docker run' command is performed... so you can load your own /workspace/liquibase.properties file and put ${DATABASE} in it, and it will be replaced with the LIQUIBASE_DATABASE environment variable.

If you want to see what the contents of the generated liquibase.properties file are, you can:

$ docker run image-name cat liquibase.properties

Tag summary

Content type

Image

Digest

Size

56.5 MB

Last updated

over 7 years ago

docker pull kilna/liquibase-sqlite