Skip to content

Commit f8c750b

Browse files
author
Leopoldo Muller
committed
Support for initialization scripts
1 parent 722548b commit f8c750b

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ EXPOSE 8080
2323

2424
# Set the default command to run on boot
2525
# This will boot WildFly in the standalone mode and bind to all interface
26-
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
26+
COPY entrypoint.sh /entrypoint.sh
27+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Logging can be done in many ways. [This blog post](https://goldmann.pl/blog/2014
5151

5252
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.
5353

54+
## Initialization scripts
55+
56+
If you need additional configuration it is possible to execute CLI scripts before initialization using:
57+
58+
docker run -it -v [PATH TO YOUR SCRIPTS]:/init jboss/wildfly
59+
5460
## Extending the image
5561

5662
To be able to create a management user to access the administration console create a Dockerfile with the following content

entrypoint.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
#docker run [COMMAND] not provided
5+
if [ "$#" -eq 0 ]; then
6+
#/init directory exists and contain cli scripts
7+
if [ -d /init ] && [ $(find /init -name "*.cli" | wc -l) -gt 0 ]; then
8+
#start standalone server in admin only mode
9+
$JBOSS_HOME/bin/standalone.sh --admin-only &
10+
#wait for cli to be available
11+
sleep 2
12+
for s in /init/*.cli; do
13+
#execute cli script
14+
$JBOSS_HOME/bin/jboss-cli.sh --connect --file=$s
15+
done
16+
#shutdown admin only server
17+
$JBOSS_HOME/bin/jboss-cli.sh --connect --command=shutdown
18+
fi
19+
fi
20+
# start real server
21+
$JBOSS_HOME/bin/standalone.sh -b 0.0.0.0
22+
else
23+
#docker run [COMMAND] is provided, execute it (e.g. bash)
24+
exec "$@"
25+
fi

test/init/test.cli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
help

0 commit comments

Comments
 (0)