This application shows how to deploy a Spring Boot application with Docker (17.06.0+) using:
- Tomcat as a base image
- Docker Swarm
- Configuration
This app uses Spring Data JPA. To use it with Oracle, a JDBC driver is needed but available in the Maven Central. There two ways of addressing the issue:
- Put the ojdbc.jar in the project folder and copy it in the tomcat lib/ folder
- Put the ojdbc.jar in the enterprise maven repo and add it as a dependency.
mvn clean package
docker build . -t leward/docker-boot
docker run --rm -p 8080:8080 --name=docker-boot leward/docker-boot
docker run --rm \
-p 8080:8080 \
-e app_world=monde \
--name=docker-boot \
leward/docker-boot
echo "app.hello=bonjour" > application.properties
docker run --rm \
-p 8080:8080 \
-v $(pwd)/application.properties:/usr/local/tomcat/application.properties \
--name=docker-boot \
leward/docker-boot
(Use docker swarm init
to enable swarm mode)
Read:
Config vs Secrets
docker stack deploy -c config/dev/docker-compose.yml docker-boot
Verify the config has been loaded:
$ curl -s http://localhost:8080/hello
{"cwd":"/usr/local/tomcat","world":"dev","greeting":"bonjour dev!","hello":"bonjour"}