-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
324 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#+++++++++++++++++++++++++++++++++++++++ | ||
# Dockerfile for webdevops/liquibase:latest | ||
# -- automatically generated -- | ||
#+++++++++++++++++++++++++++++++++++++++ | ||
|
||
FROM java:latest | ||
|
||
MAINTAINER [email protected] | ||
LABEL vendor=WebDevOps.io | ||
LABEL io.webdevops.layout=8 | ||
LABEL io.webdevops.version=0.56.1 | ||
|
||
ENV LIQUIBASE_VERSION "3.5.1" | ||
ENV LIQUIBASE_DRIVER "com.mysql.jdbc.Driver" | ||
ENV LIQUIBASE_CLASSPATH "/usr/share/java/mysql.jar" | ||
ENV LIQUIBASE_URL "" | ||
ENV LIQUIBASE_USERNAME "" | ||
ENV LIQUIBASE_PASSWORD "" | ||
ENV LIQUIBASE_CHANGELOG "/liquibase/changelog.xml" | ||
ENV LIQUIBASE_CONTEXTS "" | ||
ENV LIQUIBASE_OPTS "" | ||
|
||
COPY conf/ /opt/docker/ | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -yq --no-install-recommends \ | ||
libmysql-java \ | ||
&& wget -q -O/tmp/liquibase.tar.gz "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}-bin.tar.gz" \ | ||
&& mkdir -p /opt/liquibase \ | ||
&& tar -xzf /tmp/liquibase.tar.gz -C /opt/liquibase \ | ||
&& rm -f /tmp/liquibase.tar.gz \ | ||
&& chmod +x /opt/liquibase/liquibase \ | ||
&& ln -s /opt/liquibase/liquibase /usr/local/bin/ \ | ||
&& chmod +x /opt/docker/bin/entrypoint.sh \ | ||
&& apt-get clean \ | ||
&& rm -r /var/lib/apt/lists/* | ||
|
||
ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ docker.fromOfficial("java") }} | ||
|
||
{{ docker.version() }} | ||
|
||
{{ environment.liquibase('3.5.1') }} | ||
|
||
{{ docker.copy('conf/', '/opt/docker/') }} | ||
|
||
{{ liquibase.default() }} | ||
|
||
{{ docker.entrypoint("/opt/docker/bin/entrypoint.sh") }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#!/bin/bash | ||
|
||
set -o pipefail | ||
set -o errtrace | ||
set -o nounset | ||
set -o errexit | ||
|
||
LIQUIBASE_OPTS="$LIQUIBASE_OPTS --defaultsFile=/liquibase.properties" | ||
|
||
echo -n > /liquibase.properties | ||
|
||
## Database driver | ||
if [[ -n "$LIQUIBASE_DRIVER" ]]; then | ||
echo "driver: ${LIQUIBASE_DRIVER}" >> /liquibase.properties | ||
fi | ||
|
||
## Classpath | ||
if [[ -n "$LIQUIBASE_CLASSPATH" ]]; then | ||
echo "classpath: ${LIQUIBASE_CLASSPATH}" >> /liquibase.properties | ||
fi | ||
|
||
## Database url | ||
if [[ -n "$LIQUIBASE_URL" ]]; then | ||
echo "url: ${LIQUIBASE_URL}" >> /liquibase.properties | ||
fi | ||
|
||
## Database username | ||
if [[ -n "$LIQUIBASE_USERNAME" ]]; then | ||
echo "username: ${LIQUIBASE_USERNAME}" >> /liquibase.properties | ||
fi | ||
|
||
## Database password | ||
if [[ -n "$LIQUIBASE_PASSWORD" ]]; then | ||
echo "password: ${LIQUIBASE_PASSWORD}" >> /liquibase.properties | ||
fi | ||
|
||
## Database contexts | ||
if [[ -n "$LIQUIBASE_CONTEXTS" ]]; then | ||
echo "contexts: ${LIQUIBASE_CONTEXTS}" >> /liquibase.properties | ||
fi | ||
|
||
## Database changelog file | ||
if [[ -n "$LIQUIBASE_CHANGELOG" ]]; then | ||
echo "changeLogFile: ${LIQUIBASE_CHANGELOG}" >> /liquibase.properties | ||
fi | ||
|
||
function executeLiquibase() { | ||
exec /opt/liquibase/liquibase $LIQUIBASE_OPTS "$@" | ||
} | ||
|
||
|
||
if [[ "$#" -ge 1 ]]; then | ||
TASK="$1" | ||
shift | ||
|
||
case "$TASK" in | ||
## Custom liquibase command | ||
liquibase) | ||
executeLiquibase "$@" | ||
;; | ||
|
||
## Database Update Commands | ||
update|updateCount|updateSQL|updateCountSQL) ;& | ||
## Database Rollback Commands | ||
rollback|rollbackToDate|rollbackCount|rollbackSQL|rollbackToDateSQL|rollbackCountSQL|updateTestingRollback) ;& | ||
## Diff Commands | ||
diff|diffChangeLog) ;& | ||
## Documentation Commands | ||
dbDoc) ;& | ||
## Maintenance Commands | ||
status|validate|changelogSync|changelogSyncSQL|markNextChangeSetRan|listLocks|releaseLocks|dropAll|clearCheckSums) | ||
if [[ "$#" -eq 0 ]]; then | ||
executeLiquibase "$TASK" | ||
else | ||
executeLiquibase "$TASK" "$@" | ||
fi | ||
;; | ||
|
||
## show configuration | ||
showConf) | ||
cat /liquibase.properties | ||
;; | ||
|
||
## Help | ||
help) | ||
cat <<EOF | ||
Database Update Commands | ||
------------------------------------------------------------------------------- | ||
update Updates database to current version. | ||
updateCount <value> Applies the next <value> change sets. | ||
updateSQL Writes SQL to update database to current | ||
version to STDOUT. | ||
updateCountSQL <value> Writes SQL to apply the next <value> | ||
change sets to STDOUT. | ||
Database Rollback Commands | ||
------------------------------------------------------------------------------- | ||
rollback <tag> Rolls back the database to the state it | ||
was in when the tag was applied. | ||
rollbackToDate <date/time> Rolls back the database to the state it | ||
was in at the given date/time. | ||
rollbackCount <value> Rolls back the last <value> change sets. | ||
rollbackSQL <tag> Writes SQL to roll back the database to | ||
the state it was in when the tag was | ||
applied to STDOUT. | ||
rollbackToDateSQL <date/time> Writes SQL to roll back the database to | ||
the state it was in at the given date/time | ||
version to STDOUT. | ||
rollbackCountSQL <value> Writes SQL to roll back the last <value> | ||
change sets to STDOUT. | ||
futureRollbackSQL Writes SQL to roll back the database to | ||
the current state after the changes in | ||
the changeslog have been applied. | ||
updateTestingRollback Updates the database, then rolls back | ||
changes before updating again. | ||
generateChangeLog generateChangeLog of the database to | ||
standard out. v1.8 requires the dataDir | ||
parameter currently. | ||
Diff Commands | ||
------------------------------------------------------------------------------- | ||
diff [diff parameters] Writes description of differences to | ||
standard out. | ||
diffChangeLog [diff parameters] Writes Change Log XML to update the base | ||
database to the target database to | ||
standard out. | ||
Documentation Commands | ||
------------------------------------------------------------------------------- | ||
dbDoc <outputDirectory> Generates Javadoc-like documentation based | ||
on current database and change log. | ||
Maintenance Commands | ||
------------------------------------------------------------------------------- | ||
tag <tag> "Tags" the current database state for | ||
future rollback. | ||
tagExists <tag> Checks whether the given tag is already | ||
existing. | ||
status Outputs count (list if --verbose) of unrun | ||
change sets. | ||
validate Checks the changelog for errors. | ||
changelogSync Mark all changes as executed in the | ||
database. | ||
changelogSyncSQL Writes SQL to mark all changes as executed | ||
in the database to STDOUT. | ||
markNextChangeSetRan Mark the next change set as executed in | ||
the database. | ||
listLocks Lists who currently has locks on the | ||
database changelog. | ||
releaseLocks Releases all locks on the database | ||
changelog. | ||
dropAll Drops all database objects owned by the | ||
user. Note that functions, procedures | ||
and packages are not dropped | ||
(limitation in 1.8.1). | ||
clearCheckSums Removes current checksums from database. | ||
On next run checksums will be recomputed. | ||
EOF | ||
exit 1 | ||
;; | ||
|
||
## Default task (eg. sh, bash) | ||
*) | ||
exec "$TASK" "$@" | ||
;; | ||
esac | ||
fi |
32 changes: 32 additions & 0 deletions
32
documentation/docs/content/DockerImages/dockerfiles/liquibase.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
=================== | ||
webdevops/liquibase | ||
=================== | ||
|
||
The certbot images are based on ``java`` with liquibase and mysql driver | ||
|
||
Docker image tags | ||
----------------- | ||
|
||
====================== ========================== | ||
Tag Distribution name | ||
====================== ========================== | ||
``latest`` Based on official java | ||
====================== ========================== | ||
|
||
Environment variables | ||
--------------------- | ||
|
||
========================== ============================ ============================================== | ||
Environment variable Description Default | ||
========================== ============================ ============================================== | ||
``LIQUIBASE_VERSION`` Installed Liquibase version *not changeable* | ||
``LIQUIBASE_DRIVER`` Database driver ``com.mysql.jdbc.Driver`` | ||
``LIQUIBASE_CLASSPATH`` Java class path ``/usr/share/java/mysql.jar`` | ||
``LIQUIBASE_URL`` DB url *empty* (eg. ``jdbc:mysql://host/app``) | ||
``LIQUIBASE_USERNAME`` DB username *empty* | ||
``LIQUIBASE_PASSWORD`` DB password *empty* | ||
``LIQUIBASE_CHANGELOG`` Changelog file ``/liquibase/changelog.xml`` | ||
``LIQUIBASE_CONTEXTS`` Server contexts *empty* | ||
``LIQUIBASE_OPTS`` Additional options *empty* | ||
========================== ============================ ============================================== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% import 'Dockerfile/provision.jinja2' as provision %} | ||
|
||
{% macro default(role='') -%} | ||
RUN apt-get update \ | ||
&& apt-get install -yq --no-install-recommends \ | ||
libmysql-java \ | ||
&& wget -q -O/tmp/liquibase.tar.gz "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}-bin.tar.gz" \ | ||
&& mkdir -p /opt/liquibase \ | ||
&& tar -xzf /tmp/liquibase.tar.gz -C /opt/liquibase \ | ||
&& rm -f /tmp/liquibase.tar.gz \ | ||
&& chmod +x /opt/liquibase/liquibase \ | ||
&& ln -s /opt/liquibase/liquibase /usr/local/bin/ \ | ||
&& chmod +x /opt/docker/bin/entrypoint.sh \ | ||
&& apt-get clean \ | ||
&& rm -r /var/lib/apt/lists/* | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,3 +77,6 @@ sphinx: | |
|
||
certbot: | ||
bash ./run.sh certbot | ||
|
||
liquibase: | ||
bash ./run.sh liquibase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
shared_examples 'collection::liquibase' do | ||
include_examples 'liquibase::liquibase' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'serverspec' | ||
require 'docker' | ||
require 'spec_helper' | ||
|
||
describe "Dockerfile" do | ||
before(:all) do | ||
@image = Docker::Image.build_from_dir('.', { 'dockerfile' => ENV['DOCKERFILE'] }) | ||
set :docker_image, @image.id | ||
end | ||
|
||
include_examples 'collection::liquibase' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
shared_examples 'liquibase::liquibase' do | ||
describe command('liquibase --version') do | ||
its(:exit_status) { should eq 0 } | ||
end | ||
end |