Skip to content

Commit 58a5046

Browse files
committed
docker
1 parent 6ca4011 commit 58a5046

6 files changed

Lines changed: 55 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Developer Notes
22

3-
run a local test mongodb
3+
run with docker-compose
44

5-
docker run -p 27017:27017 --rm mongo
5+
docker-compose up --build
66

7-
API Usage
7+
## API Usage
88

99
[GET]
1010

@@ -24,10 +24,6 @@ Content-Type application/json
2424

2525
}
2626

27-
run outside docker
28-
29-
./gradlew bootRun
30-
3127
## References
3228

3329
https://medium.com/hacktive-devs/building-the-backend-of-chat-applications-with-spring-webflux-and-reactive-mongodb-26347a1ddce4

backend/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM openjdk:8-jdk-alpine
2+
3+
COPY . /project
4+
RUN cd /project && ./gradlew bootJar
5+
6+
#run the spring boot application
7+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-Dblabla", "-jar","/project/build/libs/spring-boot-0.0.1.jar"]

backend/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'com.ssechat'
8-
version = '0.0.1-SNAPSHOT'
8+
version = '0.0.1'
99
sourceCompatibility = '1.8'
1010

1111
repositories {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.data.mongodb.uri=mongodb://localhost:27017/chat_app_db
1+
spring.data.mongodb.uri=mongodb://${DB_HOST:localhost}:27017/chat_app_db
22
logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG
33
## Hibernate Logging
44
logging.level.org.hibernate.SQL=DEBUG

client/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mhart/alpine-node:14 AS builder
2+
WORKDIR /app
3+
COPY . .
4+
RUN yarn run build
5+
6+
FROM mhart/alpine-node:14
7+
RUN yarn global add serve
8+
WORKDIR /app
9+
COPY --from=builder /app/build .
10+
CMD ["serve", "-p", "3000", "-s", "."]

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: "2.1"
2+
3+
networks:
4+
chat:
5+
6+
services:
7+
backend:
8+
build:
9+
context: backend
10+
dockerfile: Dockerfile
11+
environment:
12+
- DB_HOST=mongodb
13+
ports:
14+
- "8080:8080"
15+
networks:
16+
- chat
17+
18+
client:
19+
build:
20+
context: client
21+
dockerfile: Dockerfile
22+
ports:
23+
- "3000:3000"
24+
networks:
25+
- chat
26+
27+
mongodb:
28+
image: mongo
29+
container_name: mongodb
30+
ports:
31+
- "27017:27017"
32+
networks:
33+
- chat

0 commit comments

Comments
 (0)