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-16200



 DevOps :: Support Docker like Liquibase Command Line #268

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/test/scripts/liquibase_update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
: ${CHANGELOG_FILE:="/changelog/changelog.sql"}
: ${CHANGELOG_FILE:="changelog.sql"}
: ${DEFAULTS_FILE:="/liquibase/changelog/liquibase-mssql.properties"}

echo "Applying changes to the database. Changelog: $CHANGELOG_FILE"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
# Check if the container is running
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then
# Get the logs and check if the desired string is present
if docker exec $CONTAINER_NAME liquibase update --defaultsFile=/liquibase/changelog/liquibase.properties --changelog-file=/changelog/example-changelog.xml 2>&1 | grep -q "$LOG_STRING"; then
if docker exec $CONTAINER_NAME liquibase update --defaultsFile=/liquibase/changelog/liquibase.properties --changelog-file=example-changelog.xml 2>&1 | grep -q "$LOG_STRING"; then
echo "The log contains the string: $LOG_STRING"
else
echo "The log does not contain the string: $LOG_STRING"
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
# Check if the container is running
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then
# Get the logs and check if the desired string is present
if docker exec $CONTAINER_NAME liquibase update --defaultsFile=/liquibase/changelog/liquibase.properties --changelog-file=/changelog/example-changelog.xml 2>&1 | grep -q "$LOG_STRING"; then
if docker exec $CONTAINER_NAME liquibase update --defaultsFile=/liquibase/changelog/liquibase.properties --changelog-file=example-changelog.xml 2>&1 | grep -q "$LOG_STRING"; then
echo "The log contains the string: $LOG_STRING"
else
echo "The log does not contain the string: $LOG_STRING"
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
# Start mssql docker container
docker run --name mssql --network test_network -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Letmein.8' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
# Get the logs and check if the desired string is present
docker run --rm --name $CONTAINER_NAME --network test_network -v $(pwd)/.github/test:/liquibase/changelog liquibase/liquibase:${{ github.sha }} update --defaultsFile=/liquibase/changelog/liquibase-mssql.properties --changelog-file=/changelog/changelog.sql
docker run --rm --name $CONTAINER_NAME --network test_network -v $(pwd)/.github/test:/liquibase/changelog liquibase/liquibase:${{ github.sha }} update --defaultsFile=/liquibase/changelog/liquibase-mssql.properties --changelog-file=changelog.sql

- name: Test custom entrypoint
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ RUN ln -s /liquibase/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh &&
ln -s /liquibase/liquibase /usr/local/bin/liquibase && \
ln -s /liquibase/bin/lpm /usr/local/bin/lpm

WORKDIR /liquibase
WORKDIR /liquibase/changelog
USER liquibase
ENV LIQUIBASE_HOME=/liquibase

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN addgroup --gid 1001 liquibase && \

# Make /liquibase directory and change owner to liquibase
RUN mkdir /liquibase && chown root:root /liquibase
WORKDIR /liquibase
WORKDIR /liquibase/changelog

# Copy the /liquibase directory from builder stage into final image
COPY --from=builder /liquibase /liquibase
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ The /liquibase/changelog volume can also be used for commands that write output,

### Changelog File Example

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`
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=com/example/changelogs/root.changelog.xml update`

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`
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=com/example/changelogs/root.changelog.xml generateChangeLog`

## Configuration File

Expand Down
Loading