Skip to content

Commit 4043ab2

Browse files
feat: Add dockerfile to petclinic (#60)
* feat: add spring petclinic app Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> * fix: moved the port to 9966 Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> * fix: added dockerfile Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> * Update application-postgresql.properties * fix: added mvn clean install to Dockerfile Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> * fix: fixed Dockerfile Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> --------- Signed-off-by: Pranshu Srivastava <iampranshu24@gmail.com> Co-authored-by: Gourav kumar <44055698+gouravkrosx@users.noreply.github.com>
1 parent 7b070c2 commit 4043ab2

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use an official OpenJDK runtime as a parent image
2+
FROM openjdk:22-bookworm
3+
4+
# Set the working directory to /app
5+
WORKDIR /app
6+
7+
# Install Maven
8+
RUN apt-get update && apt-get install -y maven
9+
10+
# Copy the current directory contents into the container at /app
11+
COPY . /app/
12+
13+
# Build the binary
14+
RUN mvn clean install -Dmaven.test.skip=true
15+
16+
# Expose the port the app runs on
17+
EXPOSE 9966
18+
19+
# Download the ca.crt file
20+
RUN curl -o ca.crt https://raw.githubusercontent.com/keploy/keploy/main/pkg/proxy/asset/ca.crt
21+
22+
RUN curl -o setup_ca.sh https://raw.githubusercontent.com/keploy/keploy/main/pkg/proxy/asset/setup_ca.sh
23+
24+
# Give execute permission to the setup_ca.sh script
25+
RUN chmod +x setup_ca.sh
26+
27+
# Run the application when the container launches
28+
# CMD ["java", "-jar", ""]
29+
CMD ["/bin/bash", "-c", "source ./setup_ca.sh && java -jar target/spring-petclinic-rest-3.0.2.jar"]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: "3.9"
2+
services:
3+
java-app:
4+
build:
5+
context: .
6+
container_name: javaApp
7+
depends_on:
8+
- mypostgres
9+
ports:
10+
- "9966:9966"
11+
networks:
12+
- keploy-network
13+
14+
mypostgres:
15+
image: "postgres:15.2"
16+
container_name: mypostgres
17+
ports:
18+
- "5432:5432"
19+
networks:
20+
- keploy-network
21+
volumes:
22+
- ./src/main/resources/db/postgresql/initDB.sql:/docker-entrypoint-initdb.d/initDB.sql
23+
environment:
24+
POSTGRES_USER: petclinic
25+
POSTGRES_PASSWORD: petclinic
26+
POSTGRES_DB: petclinic
27+
28+
networks:
29+
keploy-network:
30+
external: true

spring-petclinic/spring-petclinic-rest/src/main/resources/application-postgresql.properties

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

66
# PostgreSQL config start
77
#----------------------------------------------------------------
8-
spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
8+
spring.datasource.url=jdbc:postgresql://mypostgres:5432/petclinic
99
spring.datasource.username=petclinic
1010
spring.datasource.password=petclinic
1111
spring.datasource.driver-class-name=org.postgresql.Driver

0 commit comments

Comments
 (0)