Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAT-17511 update readme #309

Merged
merged 7 commits into from
Sep 4, 2024
136 changes: 77 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,129 @@
# Official Liquibase Docker images
# Official Liquibase Docker Images

[![Docker Auto Build](https://img.shields.io/docker/cloud/automated/liquibase/liquibase)][docker]
## 🚨 Notice: New Official Liquibase Docker Image 🚨

[docker]: https://hub.docker.com/r/liquibase/liquibase
We are excited to announce that a new official Liquibase Docker image is now available at [https://hub.docker.com/_/liquibase](https://hub.docker.com/_/liquibase) starting with liquibase 4.27.0 and newer. We recommend all users to start using this image for the latest updates and support. Any versions prior to 4.27.0 will only be available on the existing `liquibase/liquibase` community image.

This is the official repository for [Liquibase](https://download.liquibase.org/) images.
### 🔧 Action Required

## BREAKING CHANGE
Please update your Dockerfiles and scripts to pull from the new official image:

Support for Snowflake database has been moved from the external extension liquibase-snowflake into the main Liquibase artifact. This means that Snowflake is now included in the main docker image. If you are using the snowflake extension remove it from your lib directory or however you are including it in your project. If you are using the Docker image, use the main v4.12+ as there will no longer be a snowflake separate docker image produced. The latest separate Snowflake image will be v4.11. You need to update your reference to either latest to use the main one that includes Snowflake or the version tag you prefer. <https://github.com/liquibase/liquibase/pull/2841>
## Dockerfile

## Image Flavours
```dockerfile
FROM liquibase:latest
```

The following tags are officially supported:
## Scripts

https://hub.docker.com/r/liquibase/liquibase/tags
```bash
docker pull liquibase
```

### liquibase:<version>
In the future, we will stop updating the community `liquibase/liquibase` Docker image. Transition to the new official image to ensure you continue receiving updates and support.

This `liquibase:<version>` image is considered the standard choice. If you're uncertain about your specific requirements, it's recommended to opt for this image. It is designed to serve as a disposable container as well as a foundational building block for creating other images.
For any questions or support, please visit our [Liquibase Community Forum](https://forum.liquibase.org/).

### liquibase:<version>-alpine
---

The `liquibase:<version>-alpine` image is a slimmed-down version of the Liquibase Docker container (`liquibase:<version>`). It is designed to be lightweight and have a smaller footprint, making it suitable for environments with limited resources or when only the essential functionality is required. This image is built upon the popular [Alpine Linux](https://alpinelinux.org/) project, which can be found in the official Alpine image. Alpine Linux stands out for its significantly smaller size compared to other distribution base images, typically around **5MB**. As a result, it enables the creation of overall slimmer images.
This is the community repository for [Liquibase](https://download.liquibase.org/) images.

If your main concern is minimizing the final image size, this flavor proves to be quite useful. However, it is important to note that certain software may encounter issues depending on their specific `libc` requirements or assumptions.
## 🚨 BREAKING CHANGE

To keep the image size to a minimum, additional tools such as `git` or `bash` are not commonly included in Alpine-based images. Instead, you can utilize this image as a foundation and add the necessary components in your own Dockerfile.
Support for Snowflake database has been moved from the external extension liquibase-snowflake into the main Liquibase artifact. This means that Snowflake is now included in the main docker image. If you are using the snowflake extension, remove it from your lib directory or however you are including it in your project. If you are using the Docker image, use the main v4.12+ as there will no longer be a snowflake separate docker image produced. The latest separate Snowflake image will be v4.11. You need to update your reference to either latest to use the main one that includes Snowflake or the version tag you prefer. <https://github.com/liquibase/liquibase/pull/2841>

#### Extending liquibase:<version>-alpine
## 🏷️ Supported Tags

To extend the functionality of the `liquibase:<version>-alpine` image and include additional tools that are not included by default. Examples are provided in the [examples](/examples) directory as `Dockerfile.alpine.<EXAMPLE>`.
The following tags are officially supported and can be found on [Docker Hub](https://hub.docker.com/r/liquibase/liquibase/tags):

## Changelog File
- `liquibase/liquibase:<version>`
- `liquibase/liquibase:<version>-alpine`

The docker image has a /liquibase/changelog volume in which the directory containing the root of your changelog tree can be mounted. Your `--changeLogFile` argument should list paths relative to this.
## 📦 Using the Docker Image

The /liquibase/changelog volume can also be used for commands that write output, such as `generateChangeLog`. Note that in this case (where liquibase should write a new file) you need to specify the absolute path to the changelog, i.e. prefix the path with `/liquibase/changelog/<PATH TO CHANGELOG FILE>`.
### 🏷️ Standard Image

### Changelog File Example
The `liquibase/liquibase:<version>` image is the standard choice. Use it as a disposable container or a foundational building block for other images.

If you have a local `c:\projects\my-project\src\main\resources\com\example\changelogs\root.changelog.xml` file, you would run `docker run --rm -v c:\projects\my-project\src\main\resources:/liquibase/changelog liquibase/liquibase --changeLogFile=changelog/com/example/changelogs/root.changelog.xml update`
For examples of extending the standard image, see the [standard image examples](https://github.com/liquibase/docker/tree/main/examples).

To generate a new changelog file at this location, run `docker run --rm -v c:\projects\my-project\src\main\resources:/liquibase/changelog liquibase/liquibase --changeLogFile=changelog/com/example/changelogs/root.changelog.xml generateChangeLog`
### 🏷️ Alpine Image

## Configuration File
The `liquibase/liquibase:<version>-alpine` image is a lightweight version designed for environments with limited resources. It is built on Alpine Linux and has a smaller footprint.

If you would like to use a "default file" to specify arguments rather than passing them on the command line, include it in your changelog volume mount and reference it.
For examples of extending the alpine image, see the [alpine image examples](https://github.com/liquibase/docker/tree/main/examples).

If specifying a custom liquibase.properties file, make sure you include `searchPath=/liquibase/changelog` so Liquibase will continue to look for your changelog files there.
### 📄 Using the Changelog File

### Configuration File Example
Mount your changelog directory to the `/liquibase/changelog` volume and use relative paths for the `--changeLogFile` argument.

If you have a local `c:\projects\my-project\src\main\resources\liquibase.properties` file, you would run `docker run --rm -v c:\projects\my-project\src\main\resources:/liquibase/changelog liquibase/liquibase --defaultsFile=liquibase.properties update`
#### Example

## Drivers and Extensions
```shell
docker run --rm -v /path/to/changelog:/liquibase/changelog liquibase/liquibase --changeLogFile=changelog.xml update
```

The Liquibase docker container ships with drivers for many popular databases. If your driver is not included or if you have an extension, you can mount a local directory containing the jars to `/liquibase/lib`.
### ⚙️ Using a Configuration File

### Driver and Extensions Example
To use a default configuration file, mount it in your changelog volume and reference it with the `--defaultsFile` argument.

If you have a local `c:\projects\my-project\lib\my-driver.jar` file, `docker run --rm -v c:\projects\my-project\src\main\resources:/liquibase/changelog -v c:\projects\my-project\lib:/liquibase/lib liquibase/liquibase update`
#### Example

### Notice for MySQL Users
```shell
docker run --rm -v /path/to/changelog:/liquibase/changelog liquibase/liquibase --defaultsFile=liquibase.properties update
```

### 📚 Including Drivers and Extensions

Mount a local directory containing additional jars to `/liquibase/lib`.

Due to licensing restrictions for the MySQL driver, this container does not ship with the MySQL driver installed. Two options exist for loading this driver: 1. Create a new container from the `liquibase/liquibase` image. 2. Load this driver during runtime via an environment variable.
#### Example

### New Container Example
```shell
docker run --rm -v /path/to/changelog:/liquibase/changelog -v /path/to/lib:/liquibase/lib liquibase/liquibase update
```

Dockerfile
### 🔍 MySQL Users

Due to licensing restrictions, the MySQL driver is not included. Add it either by extending the image or during runtime via an environment variable.

#### Extending the Image

Dockerfile:

```dockerfile
FROM liquibase/liquibase
FROM liquibase

RUN lpm add mysql --global
```

Build
Build:

```shell
docker build . -t liquibase/liquibase-mysql
docker build . -t liquibase-mysql
```

### Runtime Example
#### Runtime

```shell
docker run -e INSTALL_MYSQL=true liquibase/liquibase update
```

## Complete Examples
## 🛠️ Complete Example

### Specify everything via arguments
Here is a complete example using environment variables and a properties file:

`docker run --rm -v <PATH TO CHANGELOG DIR>:/liquibase/changelog liquibase/liquibase --url="jdbc:sqlserver://<IP OR HOSTNAME>:1433;database=<DATABASE>;" --changeLogFile=com/example/changelog.xml --username=<USERNAME> --password=<PASSWORD> --liquibaseProLicenseKey="<PASTE LB PRO LICENSE KEY HERE>" update`
### Environment Variables Example

Using with [Liquibase Pro Environment Variables](https://docs.liquibase.com/concepts/basic/liquibase-environment-variables.html) example:
`docker run --env LIQUIBASE_COMMAND_USERNAME --env LIQUIBASE_COMMAND_PASSWORD --env LIQUIBASE_COMMAND_URL --env LIQUIBASE_PRO_LICENSE_KEY --env LIQUIBASE_COMMAND_CHANGELOG_FILE --rm -v <PATH TO CHANGELOG DIR>/changelogs:/liquibase/changelog liquibase/liquibase --log-level=info update`
```shell
docker run --env LIQUIBASE_COMMAND_USERNAME --env LIQUIBASE_COMMAND_PASSWORD --env LIQUIBASE_COMMAND_URL --env LIQUIBASE_PRO_LICENSE_KEY --env LIQUIBASE_COMMAND_CHANGELOG_FILE --rm -v /path/to/changelog:/liquibase/changelog liquibase/liquibase --log-level=info update
```

### Using a properties file
### Properties File Example

*liquibase.docker.properties file:*
`liquibase.docker.properties` file:

```dockerfile
```properties
searchPath: /liquibase/changelog
url: jdbc:postgresql://<IP OR HOSTNAME>:5432/<DATABASE>?currentSchema=<SCHEMA NAME>
changeLogFile: changelog.xml
Expand All @@ -110,25 +132,21 @@ password: <PASSWORD>
liquibaseProLicenseKey=<PASTE LB PRO LICENSE KEY HERE>
```

*CLI:*
CLI:

`docker run --rm -v <PATH TO CHANGELOG DIR>:/liquibase/changelog liquibase/liquibase --defaultsFile=liquibase.docker.properties update`
or
`docker run --rm -v <PATH TO CHANGELOG DIR>:/liquibase/changelog liquibase/liquibase --defaultsFile=liquibase.docker.properties --changeLogFile=changelog.xml generateChangeLog` (the argument `--changeLogFile` wins against the defaultsFile)
```shell
docker run --rm -v /path/to/changelog:/liquibase/changelog liquibase/liquibase --defaultsFile=liquibase.docker.properties update
```

### Example JDBC Urls
## 🔗 Example JDBC URLs

- MS SQL Server: `jdbc:sqlserver://<IP OR HOSTNAME>:1433;database=<DATABASE>`
- PostgreSQL: `jdbc:postgresql://<IP OR HOSTNAME>:5432/<DATABASE>?currentSchema=<SCHEMA NAME>`
- MySQL: `jdbc:mysql://<IP OR HOSTNAME>:3306/<DATABASE>`
- MariaDB: `jdbc:mariadb://<IP OR HOSTNAME>:3306/<DATABASE>`
- DB2: `jdbc:db2://<IP OR HOSTNAME>:50000/<DATABASE>`
- Snowflake: `jdbc:snowflake://<IP OR HOSTNAME>/?db=<DATABASE>&schema=<SCHEMA NAME>`
- Sybase `jdbc:jtds:sybase://<IP OR HOSTNAME>:/<DATABASE>`
- Sybase: `jdbc:jtds:sybase://<IP OR HOSTNAME>:/<DATABASE>`
- SQLite: `jdbc:sqlite:/tmp/<DB FILE NAME>.db`

Note: If the database IP refers to a locally running docker container then one needs to specify host networking like `docker run --network=host -rm -v ...`

### Adding Native Executors

The recommended path for adding native executors/binaries such as Oracle SQL*Plus, Microsoft SQLCMD, Postgres PSQL, or the AWS CLI is to extend the liquibase/liquibase Dockerfile. Examples are provided in the [Examples](https://github.com/liquibase/docker/tree/main/examples) Directory.
For more details, visit our [Liquibase Documentation](https://docs.liquibase.com/).
Loading