Spring Boot / Mongo Docker Container and NGINX Reverse Proxy | Become A Techie



Spring Boot / Mongo Docker Container and NGINX Reverse Proxy | Become A Techie

Spring Boot / Mongo Docker Container and NGINX Reverse Proxy | Become A Techie

https://www.facebook.com/HowtoBecomeATechie
This Session will cover “how to run a Spring Boot Mongodb application on a Docker container with Proxy server as NGINX Docker”.
Spring Boot Source Code : https://github.com/binoyjava/SpringBootMongoDB
Spring boot docker : https://hub.docker.com/repository/docker/binoykalathiparambil/springboot-mongo
Docker Compose File: docker-compose.yml (on work space root folder)
——————————————————————————————————————————–
version: “2”
services:
app:
container_name: app
image: binoykalathiparambil/springboot-mongo
restart: always
ports:
– “8080:8080”
links:
– mongo
mongo:
container_name: mongo
image: mongo
volumes:
– ./data:/data/db
ports:
– “27017:27017”
nginx:
container_name: nginx
image: nginx
restart: always
volumes:
– ./conf:/etc/nginx/conf.d
– ./html:/usr/share/nginx/html
ports:
– “80:80”
links:
– app
———————————————————————————————————————–
NGINX conf file: conf/default.conf
————————————————————————————————————————
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api/ {
proxy_pass http://app:8080/api/;
}
}
————————————————————————————————————————
Sample html file: html/index.html
A simple html file you can use!
————————————————————————————————————————
Command to deploy the Dockers:
$_ docker-compose up
Command to login to docker:
docker exec -it [container id] bash