Add docker image build
This commit is contained in:
13
SmartClinicManagementSystem/app/Dockerfile
Normal file
13
SmartClinicManagementSystem/app/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
# Step 1: Use Maven with JDK 21 to build the app
|
||||
FROM gradle:8.14.3-jdk21-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY build.gradle .
|
||||
COPY src ./src
|
||||
RUN gradle clean bootJar -DskipTests
|
||||
|
||||
# Step 2: Use lightweight JRE 21 for running the app
|
||||
FROM eclipse-temurin:21-jre-alpine-3.22
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/build/libs/app-1.0.0.jar app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
@@ -1,5 +1,9 @@
|
||||
import org.springframework.boot.gradle.plugin.SpringBootPlugin
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '3.5.7'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
|
||||
@@ -28,11 +32,11 @@ dependencies {
|
||||
runtimeOnly 'com.mysql:mysql-connector-j'
|
||||
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
|
||||
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.9.3"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-params:5.9.3"
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.9.3"
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -10,7 +10,7 @@ spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.format_sql=true
|
||||
spring.jpa.open-in-view=false
|
||||
|
||||
spring.data.mongodb.uri=mongodb://root:cms@localhost:27017/prescriptions?authSource=admin
|
||||
spring.data.mongodb.uri=${SPRING_DATA_MONGODB_URI:mongodb://root:cms@localhost:27017/prescriptions?authSource=admin}
|
||||
|
||||
logging.level.org.springframework.jdbc.datasource.init=DEBUG
|
||||
spring.sql.init.mode=always
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ./app
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
mongo:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
SPRING_DATASOURCE_URL: jdbc:mysql://root:cms@mysql:3306/cms
|
||||
SPRING_DATA_MONGODB_URI: mongodb://root:cms@mongo:27017/prescriptions?authSource=admin
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql
|
||||
@@ -9,6 +23,11 @@ services:
|
||||
- mysql-data:/var/lib/mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
healthcheck:
|
||||
test: ["CMD", "mysql", "-uroot", "-pcms", "-e", "SELECT 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
mongo:
|
||||
image: mongo:8.2.1
|
||||
@@ -21,6 +40,11 @@ services:
|
||||
- mongodb-data:/data/db
|
||||
ports:
|
||||
- "27017:27017"
|
||||
healthcheck:
|
||||
test: [ "CMD", "mongosh", "--quiet", "--eval", "db.runCommand({ ping: 1 })" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
mysql-data:
|
||||
|
||||
Reference in New Issue
Block a user