This script is designed to allow simpler Docker containers for Clojure apps in dev and production using Immutant 2.
When run without a linked "wildfly" container, it just executes lein run
.
When run with a linked "wildfly" container, it will deploy the .war file into the WildFly application server, sleep indefinitely, and undeploy the .war file when stopped.
Put the deploy-or-run
script in your container and run it as the CMD in your Dockerfile.
It will pull the name of your app from the (defproject ...)
form in your project.clj
file
and deploy [app].war
from your target/
directory (so make sure you run lein immutant war
in your Docker build process).
To run the container in standalone mode (lein run):
docker build -t your-image-tag .
docker run -P -d your-image-tag
To deploy to a WildFly container:
- Create a derivative of the
jboss/wildfly
image that adds an admin user and binds the management port on 0.0.0.0.- Example Dockerfile:
FROM jboss/wildfly
RUN /opt/jboss/wildfly/bin/add-user.sh admin password --silent
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
- Build and run your WildFly container
docker build -t your-wildfly-image .
docker run -d --name wildfly your-wildfly-image
docker build -t your-image-tag .
docker run --link wildfly:wildfly -d your-image-tag
> docker build -t your.repo/didor .
> docker push your.repo/didor
- Put a permissive license on this.
- Build the .war on demand if it's missing and there's a linked wildfly container.
- Create a leiningen template that pre-installs this script and its Clojure dependencies.