Skip to content

Commit f65077d

Browse files
authored
App containerization (#2)
Dockerized the apps in compose
1 parent 75e74db commit f65077d

11 files changed

Lines changed: 68 additions & 22 deletions

File tree

.README.md.swp

12 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ hs_err_pid*
2424
/.metadata/
2525

2626
/target/
27+
28+
# DataDir Volumes causing permissions issues
2729
docker/mysql/datadir/*
30+
!docker/mysql/datadir/test.txt
2831

2932
# Flight Service Project
3033

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
- sudo apt-get install openjdk-11-jdk
4848
- java --version
4949

50+
- maven 3.6.3
51+
- curl https://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o "apache-maven-3.6.3-bin.tar.gz"
52+
- tar -xvf apache-maven-3.6.3-bin.tar.gz
53+
- mv apache-maven-3.6.3 ~/bin/
54+
- M2_HOME='~/bin/apache-maven-3.6.3'
55+
- PATH="$M2_HOME/bin:$PATH"
56+
- export PATH
57+
5058
- VSCode extensions installed for WSL
5159
* Docker
5260
* Java Extension Pack
@@ -56,8 +64,9 @@
5664
* MySQL Extension
5765

5866
## Get Started with the Project
59-
1. Clone the Git Repository in WSL
60-
2. Start the Docker
67+
1. Clone the Git Repository in WSL at your "repos" location
68+
2. Start the Docker service
69+
3.
6170

6271
## Creating a springboot project
6372
1. Create a new Spring Project with Maven
@@ -66,3 +75,19 @@
6675
- MySQL Driver
6776
- Spring web
6877

78+
## Postman calls to create Coupon & Products
79+
- Create a coupon
80+
{
81+
"code":"XMAS",
82+
"discount":25,
83+
"expDate":"26/12/2022"
84+
}
85+
86+
- Create a product
87+
{
88+
"name":"X-mas Tree",
89+
"description": "A must have in your Xmas decoration",
90+
"price": 75,
91+
"couponCode": "XMAS"
92+
}
93+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM openjdk:11
2+
ADD couponservice/target/couponservice-0.0.1-SNAPSHOT.jar couponservice-0.0.1-SNAPSHOT.jar
3+
ENTRYPOINT [ "java", "-jar", "couponservice-0.0.1-SNAPSHOT.jar" ]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.datasource.url=jdbc:mysql://127.0.0.1:3010/mydb
1+
spring.datasource.url=jdbc:mysql://web-db:3010/mydb
22
spring.datasource.username=admin
33
spring.datasource.password=admin
44
server.port=8090

docker-compose.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,31 @@ services:
2020
healthcheck:
2121
test: "/etc/init.d/mysql status -P3310"
2222
interval: 2s
23-
retries: 10
23+
retries: 10
24+
25+
coupon-app:
26+
build:
27+
context: .
28+
dockerfile: ./couponservice/Dockerfile
29+
environment:
30+
- TZ=America/Chicago
31+
container_name: coupon-app
32+
mem_limit: 1G
33+
mem_reservation: 1G
34+
ports:
35+
- "8090:8090"
36+
depends_on:
37+
- web-db
38+
39+
product-app:
40+
build:
41+
context: .
42+
dockerfile: ./productservice/Dockerfile
43+
container_name: product-app
44+
mem_limit: 1G
45+
mem_reservation: 1G
46+
ports:
47+
- "8091:8091"
48+
depends_on:
49+
- web-db
50+
- coupon-app

docker/mysql/datadir/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a test file in datadir

info.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

productservice/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM openjdk:11
2+
ADD productservice/target/productservice-0.0.1-SNAPSHOT.jar productservice-0.0.1-SNAPSHOT.jar
3+
ENTRYPOINT [ "java", "-jar", "productservice-0.0.1-SNAPSHOT.jar" ]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
spring.datasource.url=jdbc:mysql://127.0.0.1:3010/mydb
1+
spring.datasource.url=jdbc:mysql://web-db:3010/mydb
22
spring.datasource.username=admin
33
spring.datasource.password=admin
44
server.port=8091
5-
couponService.url=http://localhost:8090/couponapi/coupons/
5+
couponService.url=http://coupon-app:8090/couponapi/coupons/

0 commit comments

Comments
 (0)