Skip to content

Commit

Permalink
feat: build Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
yutaro-sakamoto committed Nov 25, 2024
1 parent c1d119d commit 3710362
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/server-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
java-version: "17"

- name: Build with Gradle
run: ./gradlew bootJar
run: ./gradlew buildDockerImage

#- name: Run tests
# if: ${{ github.event.inputs.run_tests }}
Expand Down
15 changes: 15 additions & 0 deletions server/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ベースイメージを指定
FROM openjdk:17-jdk-alpine

# 作業ディレクトリを作成
WORKDIR /app

# 依存関係のコピー
COPY lib /app/lib

# アプリケーションのJARファイルをコピー
ARG JAR_FILE=build/libs/app.jar
COPY ${JAR_FILE} app.jar

# アプリケーションを実行
ENTRYPOINT ["java", "-cp", "app.jar:lib/*", "org.springframework.boot.loader.JarLauncher"]
12 changes: 12 additions & 0 deletions server/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ val javaDir = "${project.projectDir}/src/main/java/cobol4j/aws/web/"
val libDir = "${project.projectDir}/lib"
val libLibcobjJar = "${libDir}/libcobj.jar"
val javaPackage = "cobol4j.aws.web"
val dockerImageTag = "cobol4j-aws-web:latest"

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
Expand Down Expand Up @@ -158,7 +159,18 @@ tasks.register<Exec>("buildCobol") {
""")
}


tasks.named("compileJava") {
dependsOn("buildCobol")
dependsOn("moveLibcobjJar")
}

tasks.register<Exec>("buildDockerImage") {
dependsOn("compileJava")

inputs.files(
file("Dockerfile"),
)

commandLine("sh", "-c", "docker build -t ${dockerImageTag} .")
}

0 comments on commit 3710362

Please sign in to comment.