Docker
Dockerfile
There is a known incompatibility with the Dockerfile in the webswing-evaluation version. Please use the Dockerfile below or contact support
You can find an example Dockerfile in the standard Webswing distribution with examples. In case you need to create a Docker image with Webswing you can do so by using&extending it. Extract the distribution.zip file and execute:
docker build -t webswing .
docker run -d -p 8080:8080 webswing
This is the Dockerfile you can find in the standard Webswing distribution with examples. It relies on the xheadless which is present only in the distribution with examples.
FROM openjdk:11-jdk-bullseye
RUN apt-get update && apt-get install --no-install-recommends -y \
wget \
unzip \
xvfb \
libxext6 \
libxi6 \
libxtst6 \
libxrender1 \
libpangoft2-1.0-0
COPY . /opt/webswing/
ENV WEBSWING_HOME=/opt/webswing \
DISPLAY=:99 \
WEBSWING_OPTS="-h 0.0.0.0 -j /opt/webswing/jetty.properties -serveradmin -pfa /opt/webswing/admin/webswing-admin.properties -adminctx /admin -aw admin/webswing-admin-server.war" \
WEBSWING_JAVA_OPTS="-Xmx256M -Djava.net.preferIPv4Stack=true -Dwebswing.admin.url=http://localhost:8080/admin"
WORKDIR /opt/webswing
RUN mkdir -p /etc/service/xvfb && \
echo "#!/bin/sh\nexec Xvfb :99" > /etc/service/xvfb/run && \
chmod +x /etc/service/xvfb/run
RUN mkdir /etc/service/webswing && \
echo "#!/bin/sh\ncd $WEBSWING_HOME\nexec $JAVA_HOME/bin/java \$WEBSWING_JAVA_OPTS -jar $WEBSWING_HOME/server/webswing-jetty-launcher.jar -w $WEBSWING_HOME/webswing-server.war \$WEBSWING_OPTS" > /etc/service/webswing/run && \
chmod +x /etc/service/webswing/run
EXPOSE 8080
RUN echo "#!/bin/sh" > ./start.sh && \
echo "rm -f /tmp/.X99-lock" >> ./start.sh && \
echo "/etc/service/xvfb/run & /etc/service/webswing/run" >> ./start.sh && \
chmod +x ./start.sh
CMD ./start.sh
Quick startup
Running locally:
docker run -d --rm -p 8080:8080 webswing
Running on a server:
docker run -d --rm -e WEBSWING_JAVA_OPTS="-Xmx256M -Djava.net.preferIPv4Stack=true -Dwebswing.admin.url=/admin -Dwebswing.server.publicUrl=http://192.168.1.88:8080" -p 8080:8080 webswing
These images are not meant for cluster deployment, please refer to Cluster Deployment section if you need docker images for cluster deployment.
Docker Compose Example:
Create docker-compose.yml file:
version: "3.3"
services:
webswing:
image: webswing
environment:
- WEBSWING_OPTS=-h 0.0.0.0 -serveradmin -pfa /opt/webswing/admin/webswing-admin.properties -adminctx /admin -aw admin/webswing-admin-server.war -c /opt/app/webswing.config
- WEBSWING_JAVA_OPTS=-Xmx256M -Djava.net.preferIPv4Stack=true -Dwebswing.admin.url=http://192.168.1.2:8080/admin -Dwebswing.server.publicUrl=http://192.168.1.88:8080
volumes:
- /opt/app:/opt/app
ports:
- "80:8080"
Environment variable WEBSWING_OPTS
specifies startup arguments for the server.
You can reference your webswing.config
here. Volume syncs container with host, so your config survives the restart of container.
Environment variable WEBSWING_JAVA_OPTS
is for specifying all the system properties that needs to be changed. The most important one in docker context is webswing.admin.url
that is mapped in webswing.config
. This URL link is behind the Manage
button in the application selector screen.
Please note that admin console can run in a different container/host/server, or not run if it is not needed.
In the docker-compose example file we expect that the server has IP address 192.168.1.2.
Docker ports are of "host:container" syntax. So with "80:8080" your app will be accessible without specifying port number.
On your host create folder /opt/app
and place there application jar and dependencies in /opt/app/lib
.
Copy webswing.config
from your DEV machine to /opt/app/webswing.config
.
To configure your app setup the classpath like following:
"classPathEntries" : [ "/opt/app/lib/*.jar", "/opt/app/MySwingApp.jar" ]
Run
docker-compose up -d