This tutorial will walk you through the steps of creating and running a sample Spring Boot application and an NGINX proxy server as Docker Compose services
What you'll need
- Docker CE
Stack
- Docker
- Spring Boot
- NGINX
- Maven
Init project structure and dependencies
Project structure
├── app
│ ├── src
│ │ └── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── hellokoding
│ │ │ └── springboot
│ │ │ ├── IndexController.java
│ │ │ └── WebApplication.java
│ │ └── resources
│ │ ├── static
│ │ │ ├── css
│ │ │ │ └── main.css
│ │ │ └── js
│ │ │ └── main.js
│ │ ├── templates
│ │ │ └── index.ftl
│ │ └── application.properties
│ ├── Dockerfile
│ └── pom.xml
├── nginx
│ └── conf.d
│ └── app.conf
└── docker-compose.yaml
Application dependencies
Define Controller, View Template and Config
Controller
FreeMarker View template
Static files
Application Configuration
Dockerize
Dockerfile of Spring Boot web application
NGINX config file
Docker Compose
Test
- Run command
docker-compose up
- Access to
http://localhost