Skip to content

Commit

Permalink
Support for initialization scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldo Muller committed May 5, 2016
1 parent 722548b commit f8c750b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ EXPOSE 8080

# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Logging can be done in many ways. [This blog post](https://goldmann.pl/blog/2014

Sometimes you need to customize the application server configuration. There are many ways to do it and [this blog post](https://goldmann.pl/blog/2014/07/23/customizing-the-configuration-of-the-wildfly-docker-image/) tries to summarize it.

## Initialization scripts

If you need additional configuration it is possible to execute CLI scripts before initialization using:

docker run -it -v [PATH TO YOUR SCRIPTS]:/init jboss/wildfly

## Extending the image

To be able to create a management user to access the administration console create a Dockerfile with the following content
Expand Down
25 changes: 25 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -e

#docker run [COMMAND] not provided
if [ "$#" -eq 0 ]; then
#/init directory exists and contain cli scripts
if [ -d /init ] && [ $(find /init -name "*.cli" | wc -l) -gt 0 ]; then
#start standalone server in admin only mode
$JBOSS_HOME/bin/standalone.sh --admin-only &
#wait for cli to be available
sleep 2
for s in /init/*.cli; do
#execute cli script
$JBOSS_HOME/bin/jboss-cli.sh --connect --file=$s
done
#shutdown admin only server
$JBOSS_HOME/bin/jboss-cli.sh --connect --command=shutdown
fi
fi
# start real server
$JBOSS_HOME/bin/standalone.sh -b 0.0.0.0
else
#docker run [COMMAND] is provided, execute it (e.g. bash)
exec "$@"
fi
1 change: 1 addition & 0 deletions test/init/test.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
help

0 comments on commit f8c750b

Please sign in to comment.