Skip to content

Commit 0348241

Browse files
Added docker-compose.yml
1 parent 3d97410 commit 0348241

File tree

6 files changed

+55
-8
lines changed

6 files changed

+55
-8
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
db/
2+
db/*
3+
target/*

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ HELP.md
2525
/.nb-gradle/
2626
/build/
2727

28+
### Database ###
29+
db/data/*
30+
2831
#mac-os
2932
*.DS_Store

db/.gitkeep

Whitespace-only changes.

docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '2.1'
2+
services:
3+
mongodb:
4+
image: mongo:latest
5+
restart: always
6+
container_name: "mongodb"
7+
environment:
8+
- MONGO_DATA_DIR=/db/data
9+
- MONGO_LOG_DIR=/dev/null
10+
volumes:
11+
- ./db/data:/data/db
12+
ports:
13+
- 27017:27017
14+
command: mongod --bind_ip_all --smallfiles --logpath=/dev/null # --quiet
15+
16+
web:
17+
build: .
18+
links:
19+
- mongodb
20+
container_name: BRS-Service
21+
restart: always
22+
ports:
23+
- "8080:8080"
24+
environment:
25+
- MONGODB_PORT=27017
26+
- MONGODB_SCHEMA=brs
27+
- MONGODB_HOST=mongodb
28+
- LOG_LEVEL=DEBUG
29+
depends_on:
30+
- mongodb

readme.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The _End user_ can use their mobile application (yet to be built, however the RE
9090
5. Filter search results with a date option
9191
6. Book a ticket for a given trip schedule
9292

93-
Admin interface and REST APIs both have their independent authentication mechanisms, the web application uses the cookie based authentication (provided by default by Spring security) and the RESTAPI uses the JWT authentication for access. This application assumes the availability of 'MongoDB' installation on the localhost where the server will run or the use of docker-compose to boot up a mongodb container and link the application with it within the realm of docker.
93+
Admin interface and REST APIs both have their independent authentication mechanisms, the web application uses the cookie based authentication (provided by default by Spring security) and the REST API uses the JWT authentication for access. This application assumes the availability of 'MongoDB' installation on the localhost where the server will run or the use of docker-compose to boot up a mongodb container and link the application with it within the realm of docker.
9494

9595
Any changes that the admin users will do on the web portal will impact the search results of the end users, there will be certain use cases which you may find missing here, I hope you will appreciate that the overall idea was to present a way to create such an application completely inside the realm of Spring Boot and not to actually building a fully functional reservation system.
9696

@@ -153,7 +153,7 @@ I have tried to experiment a bit with the RuntimeExceptions and come up with a m
153153

154154
The BRSException class has two static classes _EntityNotFoundException_ and _DuplicateEntityException_ which are the two most widely thrown exceptions from the service layer. It also contains a set of overloaded methods _throwException_ which take the EntityType, ExceptionType and arguments to come up with a formatted message whose template is present under the **_custom.properties_** file. Using this class I was able to empower the entire services layer to throw entity exceptions in a uniform manner without cluttering the code base with all sorts of NOT_FOUND and DUPLICATE entity exceptions.
155155

156-
For example, while login if you try to use a email address which is not regisered, an exception is raised and thrown using the following single line of code -
156+
For example, while login if you try to use a email address which is not registered, an exception is raised and thrown using the following single line of code -
157157

158158
``` java
159159
throw exception(USER, ENTITY_NOT_FOUND, userDto.getEmail());
@@ -234,7 +234,7 @@ The individual areas in this layout serve the following purpose :
234234
- **Sidebar**: a sidebar for additional information
235235
- **Footer**: the footer area that provides the copyright info
236236

237-
These components can be located in the resources/templates directory at the root as well as under the sub-directories fragements and layout. The content area in this layout will host the following pages :
237+
These components can be located in the resources/templates directory at the root as well as under the sub-directories fragments and layout. The content area in this layout will host the following pages :
238238

239239
- Dashboard
240240
- Agency
@@ -268,7 +268,7 @@ You can also use Maven plugin to run the app. Use the below example to run your
268268
mvn spring-boot:run
269269
```
270270

271-
You can follow any/all of the above commands, or simply use the run configuration provided by your favorite IDE and run/debug the app from there for development purposes. Once the server is setup you should be able to access the admin interface at the following URL :
271+
You can follow any/all of the above commands, or simply use the run configuration provided by your favourite IDE and run/debug the app from there for development purposes. Once the server is setup you should be able to access the admin interface at the following URL :
272272

273273
http://localhost:8080
274274

@@ -286,6 +286,7 @@ Some of the important api endpoints are as follows :
286286
- http://localhost:8080/api/v1/reservation/bookticket (HTTP:POST)
287287

288288
## Running the server in Docker Container ##
289+
##### Docker #####
289290
Command to build the container :
290291

291292
```
@@ -300,6 +301,16 @@ docker run -p 8080:8080 spring/starterkit
300301

301302
Please **note** when you build the container image and if mongodb is running locally on your system, you will need to provide your system's IP address (or cloud hosted database's IP) in the application.properties file to be able to connect to the database from within the container.
302303

304+
##### Docker Compose #####
305+
Another alternative to run the application is to use the docker-compose.yml file and utility. To build the application using docker-compose simply execute the following command :
306+
```
307+
docker-compose build
308+
```
309+
310+
And to run the application, please execute the following command :
311+
```
312+
docker-compose up
313+
```
303314

304315
## User Interface ##
305316
Here are the various screens of the Admin portal that you should be able to use once the application is setup properly :
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
spring.data.mongodb.database=springmongodb
2-
spring.data.mongodb.host=192.168.1.100
3-
spring.data.mongodb.port=27017
4-
logging.level.web=DEBUG
1+
spring.data.mongodb.database=${MONGODB_SCHEMA:springmongodb}
2+
spring.data.mongodb.host=${MONGODB_HOST:localhost}
3+
spring.data.mongodb.port=${MONGODB_PORT:27017}
4+
logging.level.web=${LOG_LEVEL:DEBUG}
55
management.endpoints.web.exposure.include=*
66
server.error.whitelabel.enabled=false

0 commit comments

Comments
 (0)