Skip to content

Commit 5ac96bd

Browse files
authored
Merge pull request #2 from fcerbell/main
Dockerized and composed the application for easy run
2 parents 80f50fe + e142a99 commit 5ac96bd

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Build stage
3+
#
4+
FROM maven AS build
5+
COPY src /home/app/src
6+
COPY pom.xml /home/app
7+
RUN mvn -f /home/app/pom.xml clean package -Dmaven.test.skip=true
8+
9+
#
10+
# Package stage
11+
#
12+
FROM openjdk
13+
COPY --from=build /home/app/target/*.jar /app.jar
14+
EXPOSE 8080
15+
ENTRYPOINT ["java","-jar","/app.jar","--spring.profiles.active=prod"]
16+
17+

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ Features in this demo:
2727
## Running locally
2828

2929
1. Checkout the project
30-
2. `./mvnw clean package`
31-
3. `docker run -p 6379:6379 redislabs/redismod:latest`
32-
4. `./mvnw spring-boot:run`
33-
5. Navigate to http://localhost:8080 and login with user lars and password larsje
30+
2. `docker-compose.sh up`
31+
3. Navigate to http://localhost:8080 and login with user lars and password larsje
32+
4. Stop and clean with `docker-compose down -v --rmi local --remove-orphans`
3433

3534
## Running on Azure Spring Cloud
3635

@@ -69,4 +68,4 @@ Note: project is compiled with JDK11 as that's currently the max LTS version tha
6968
## Known issues
7069

7170
1. Thread safety. Data is currently generated off of a single stream of transactions, which means it's the same for all users. Not a problem with the current iteration because it's single user, but beware when expanding this to multi-user.
72-
2. Hardcoded values. Code uses hardcoded values throughout the code, these need to be replaced with proper variables.
71+
2. Hardcoded values. Code uses hardcoded values throughout the code, these need to be replaced with proper variables.

docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3.7'
2+
services:
3+
4+
app-redis:
5+
image: redislabs/redismod:latest
6+
ports:
7+
- "6379:6379"
8+
networks:
9+
- redis-bank-network
10+
restart: always
11+
12+
app-redisbank:
13+
build:
14+
context: ./
15+
dockerfile: Dockerfile
16+
environment:
17+
- REDIS_HOST=app-redis
18+
- REDIS_PORT=6379
19+
ports:
20+
- "8080:8080"
21+
networks:
22+
- redis-bank-network
23+
restart: always
24+
depends_on:
25+
- app-redis
26+
27+
networks:
28+
redis-bank-network:
29+
driver: bridge

src/main/resources/application.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
stomp.host=localhost
33
stomp.protocol=ws
44
stomp.port=8080
5-
spring.redis.host=localhost
6-
spring.redis.port=6379
5+
spring.redis.host=${REDIS_HOST:localhost}
6+
spring.redis.port=${REDIS_PORT:6379}
77

88
# Properties for running on Azure Spring Cloud
99
#stomp.host=<app>-<service>.azuremicroservices.io
@@ -19,4 +19,4 @@ stomp.destinationPrefix=/topic
1919
stomp.transactionsTopic=/topic/transactions
2020
management.endpoints.web.exposure.include=env
2121
spring.session.store-type=redis
22-
spring.session.redis.namespace={lars:}spring:session
22+
spring.session.redis.namespace={lars:}spring:session

0 commit comments

Comments
 (0)