Improve Docker start up script
- Make sure the last line contains the information - Split in separate functions - Add option to skip starting nginx (by default it is started)
This commit is contained in:
parent
d496c929b3
commit
8dd66fc0ff
@ -1,5 +1,11 @@
|
|||||||
# WebGoat release notes
|
# WebGoat release notes
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### New functionality
|
||||||
|
|
||||||
|
- Update the Docker startup script, it is now possible to pass `skip-nginx` or set `SKIP_NGINX` as environment variable.
|
||||||
|
|
||||||
## Version 8.2.2
|
## Version 8.2.2
|
||||||
|
|
||||||
### New functionality
|
### New functionality
|
||||||
|
@ -11,9 +11,10 @@ COPY --chown=webgoat index.html /usr/share/nginx/html/
|
|||||||
COPY --chown=webgoat target/webgoat-server-*.jar /home/webgoat/webgoat.jar
|
COPY --chown=webgoat target/webgoat-server-*.jar /home/webgoat/webgoat.jar
|
||||||
COPY --chown=webgoat target/webwolf-*.jar /home/webgoat/webwolf.jar
|
COPY --chown=webgoat target/webwolf-*.jar /home/webgoat/webwolf.jar
|
||||||
COPY --chown=webgoat start.sh /home/webgoat
|
COPY --chown=webgoat start.sh /home/webgoat
|
||||||
|
RUN chmod +x /home/webgoat/start.sh
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
EXPOSE 9090
|
EXPOSE 9090
|
||||||
|
|
||||||
WORKDIR /home/webgoat
|
WORKDIR /home/webgoat
|
||||||
ENTRYPOINT /bin/bash start.sh
|
ENTRYPOINT ["./start.sh"]
|
||||||
|
@ -1,26 +1,72 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd /home/webgoat
|
cd /home/webgoat
|
||||||
service nginx start
|
|
||||||
sleep 1
|
|
||||||
echo "Starting WebGoat...."
|
|
||||||
|
|
||||||
java \
|
function should_start_nginx() {
|
||||||
-Duser.home=/home/webgoat \
|
if [[ -v "${SKIP_NGINX}" ]]; then
|
||||||
-Dfile.encoding=UTF-8 \
|
return 1
|
||||||
--add-opens java.base/java.lang=ALL-UNNAMED \
|
else
|
||||||
--add-opens java.base/java.util=ALL-UNNAMED \
|
for i in "${commandline_args[@]}" ; do [[ $i == "skip-nginx" ]] && return 1 ; done
|
||||||
--add-opens java.base/java.lang.reflect=ALL-UNNAMED \
|
fi
|
||||||
--add-opens java.base/java.text=ALL-UNNAMED \
|
return 0
|
||||||
--add-opens java.desktop/java.beans=ALL-UNNAMED \
|
}
|
||||||
--add-opens java.desktop/java.awt.font=ALL-UNNAMED \
|
|
||||||
--add-opens java.base/sun.nio.ch=ALL-UNNAMED \
|
function nginx() {
|
||||||
--add-opens java.base/java.io=ALL-UNNAMED \
|
if should_start_nginx; then
|
||||||
-jar webgoat.jar --server.address=0.0.0.0 > webgoat.log &
|
echo "Starting nginx..."
|
||||||
|
service nginx start
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function webgoat() {
|
||||||
|
echo "Starting WebGoat...."
|
||||||
|
java \
|
||||||
|
-Duser.home=/home/webgoat \
|
||||||
|
-Dfile.encoding=UTF-8 \
|
||||||
|
--add-opens java.base/java.lang=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/java.util=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/java.lang.reflect=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/java.text=ALL-UNNAMED \
|
||||||
|
--add-opens java.desktop/java.beans=ALL-UNNAMED \
|
||||||
|
--add-opens java.desktop/java.awt.font=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/sun.nio.ch=ALL-UNNAMED \
|
||||||
|
--add-opens java.base/java.io=ALL-UNNAMED \
|
||||||
|
-jar webgoat.jar --server.address=0.0.0.0 > webgoat.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function webwolf() {
|
||||||
|
echo "Starting WebWolf..."
|
||||||
|
java -Duser.home=/home/webgoat -Dfile.encoding=UTF-8 -jar webwolf.jar --server.address=0.0.0.0 > webwolf.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function write_start_message() {
|
||||||
|
until $(curl --output /dev/null --silent --head --fail http://0.0.0.0:8080/WebGoat/health); do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "
|
||||||
|
__ __ _ _____ _
|
||||||
|
\ \ / / | | / ____| | |
|
||||||
|
\ \ /\ / / ___ | |__ | | __ ___ __ _ | |_
|
||||||
|
\ \/ \/ / / _ \ | '_ \ | | |_ | / _ \ / _' | | __|
|
||||||
|
\ /\ / | __/ | |_) | | |__| | | (_) | | (_| | | |_
|
||||||
|
\/ \/ \___| |_.__/ \_____| \___/ \__,_| \__|
|
||||||
|
" >> webgoat.log
|
||||||
|
echo "WebGoat and WebWolf successfully started..." >> webgoat.log
|
||||||
|
pidof nginx >/dev/null && echo "Browse to http://localhost to get started" >> webgoat.log || echo "Browse to http://localhost:8080/WebGoat or http://localhost:9090/WebWolf to get started" >> webgoat.log
|
||||||
|
}
|
||||||
|
|
||||||
|
function tail_log_file() {
|
||||||
|
touch webgoat.log
|
||||||
|
tail -300f webgoat.log
|
||||||
|
}
|
||||||
|
|
||||||
|
commandline_args=("$@")
|
||||||
|
|
||||||
|
nginx
|
||||||
|
webgoat &
|
||||||
|
webwolf &
|
||||||
|
write_start_message &
|
||||||
|
tail_log_file
|
||||||
|
|
||||||
echo "Starting WebWolf..."
|
|
||||||
java -Duser.home=/home/webgoat -Dfile.encoding=UTF-8 -jar webwolf.jar --server.address=0.0.0.0 > webwolf.log &
|
|
||||||
|
|
||||||
echo "Browse to http://localhost to get started" >> webgoat.log
|
|
||||||
|
|
||||||
exec tail -300f webgoat.log
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user