Skip to content

Commit

Permalink
Merge pull request #43 from appKom/add-dockerfile
Browse files Browse the repository at this point in the history
Add dockerfile for deployment
  • Loading branch information
akselsf authored Oct 20, 2024
2 parents d1d4da6 + 7f75add commit 2ce322a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
FROM gradle:7.4.1 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build

FROM openjdk:17
EXPOSE 8080
COPY --from=build /home/gradle/src/build/libs/autobank-image.jar /app/
RUN bash -c 'touch /app/autobank-image.jar'
ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/autobank-image.jar"]

10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ java {
sourceCompatibility = '17'
}

bootJar {
archiveBaseName = 'autobank-image'
archiveVersion = ''
mainClass = 'com.example.autobank.AutobankApplicationKt' // Kotlin class with 'Kt' suffix
}

repositories {
mavenCentral()
}
Expand All @@ -25,7 +31,7 @@ ext {
}

dependencies {
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.5.0.jre11-preview'
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
Expand All @@ -42,8 +48,6 @@ dependencies {
implementation "org.springframework.security:spring-security-oauth2-jose"

implementation 'com.azure:azure-storage-blob:12.27.1'


implementation 'net.coobird:thumbnailator:0.4.20'


Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/com/example/autobank/security/WebConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class WebConfig : WebMvcConfigurer {

override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000") // Replace with your frontend URL
.allowedOrigins("http://localhost:3000", "https://autobank-frontend.vercel.app") // Add your frontend URL here e.
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600)

}
}

0 comments on commit 2ce322a

Please sign in to comment.