Skip to content

Commit

Permalink
feat: add docker and demo_request.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Alikohd committed Sep 24, 2024
1 parent 34bbe0e commit fddd8e9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hello_world/MongoExample/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM maven:3.8.4-openjdk-17 AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests

FROM openjdk:17-jdk-slim
WORKDIR /app
COPY --from=build /app/target/MongoExample-1.0.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
EXPOSE 8080
10 changes: 10 additions & 0 deletions hello_world/MongoExample/demo_request.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "GET request to /messages"
curl http://localhost:8080/messages

echo -e "\nPOST request to /messages"
curl -X POST http://localhost:8080/messages -H "Content-Type: application/json" -d '{"content": "Hello, World!"}'

echo -e "GET request to /messages after POST request"
curl http://localhost:8080/messages
26 changes: 26 additions & 0 deletions hello_world/MongoExample/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.8'

services:
app:
build: .
ports:
- "8080:8080"
environment:
SPRING_DATA_MONGODB_HOST: mongo
depends_on:
- mongo
networks:
- mynetwork

mongo:
image: mongo:8.0
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
networks:
- mynetwork

networks:
mynetwork:

0 comments on commit fddd8e9

Please sign in to comment.