Skip to content

Commit

Permalink
Compose setup (#3)
Browse files Browse the repository at this point in the history
* [compose-setup][add] docker-compose.yml

* [compose-setup][add] updating db url

* [compose-setup][add] updating nginx configuration

* [compose-setup][add] adding ingress

* [compose-setup][update] updating README.md

* [compose-setup][update] resolving issues in docker-compose.yml

* [compose-setup][update] resolving issues in docker-compose.yml

* [compose-setup][add]empty line in docker-compose.yml
  • Loading branch information
iamsudipt authored Feb 13, 2020
1 parent 62ee07f commit 91b2c7c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ docker build -t opstree/spring3hibernate:latest -f Dockerfile .
```

That's it. It will create Tomcat Image having the war itself. Now just go and deploy the docker image anywhere you want.

#### Docker Compose Setup

```shell
docker-compose build
docker-compose up
```

The compose file will spinup three containers:
1) Nginx (Ingress)
2) Spring3Hibernate (JAVA APP)
3) MySql (Database)
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'
services:
spring3hibernate.okts.tk:
build:
context: .
dockerfile: Dockerfile
expose:
- '8080'
restart: always
depends_on:
- mysql.okts.tk

mysql.okts.tk:
image: mysql:5.6
restart: always
expose:
- '3306'
environment:
MYSQL_DATABASE: employeedb
MYSQL_USER: 'root'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
volumes:
- mysql_okts_tk:/var/lib/mysql

ingress.okts.tk:
build:
context: nginx
dockerfile: Dockerfile
ports:
- "80:80"
restart: always
depends_on:
- spring3hibernate.okts.tk

volumes:
mysql_okts_tk:


10 changes: 2 additions & 8 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ server {
listen 80;
server_name ingress.okts.tk;

location / {
stub_status on;
root /usr/share/nginx/html;
index index.html index.htm;
}

location /go {
proxy_pass https://www.google.com/;
}

location /tom {
proxy_pass http://tomcat-dev-default.okts-test:8080/;
location / {
proxy_pass http://spring3hibernate.okts.tk:8080/;
}

# redirect server error pages to the static page /50x.html
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/database.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://mysql.okts-test:3306/employeedb
database.url=jdbc:mysql://mysql.okts.tk:3306/employeedb
database.user=root
database.password=password
hibernate.dialect=org.hibernate.dialect.MySQLDialect
Expand Down

0 comments on commit 91b2c7c

Please sign in to comment.