Skip to content
14 changes: 12 additions & 2 deletions src/main/kotlin/com/dcd/server/core/common/file/FileContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ object FileContent {
${getEnvString(env)}
""".trimIndent()

fun getImageVersionShellScriptContent(imageName: String, minVersion: String): String =
fun getH2DBDockerFileContent(version: String, port: Int, env: Map<String, String>): String =
"""
FROM oscarfonts/h2:${version}
EXPOSE $port
${getEnvString(env)}
""".trimIndent()

fun getImageVersionShellScriptContent(imageName: String, minVersion: String): String {
val imagePrefix = if (imageName.contains("/")) "" else "library/"

return """
#!/bin/bash

# ์ด๋ฏธ์ง€, ํŽ˜์ด์ง€ ์‚ฌ์ด์ฆˆ, ์ตœ์†Œ ๋ฒ„์ „(threshold) ์„ค์ •
IMAGE_NAME="library/$imageName"
IMAGE_NAME="${imagePrefix}$imageName"
PAGE_SIZE=100
MIN_VERSION="$minVersion"

Expand Down Expand Up @@ -100,6 +109,7 @@ object FileContent {
echo "${'$'}sorted_numeric_tags"
fi
""".trimIndent()
}

fun getApplicationHttpConfig(application: Application, domain: String): String =
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ enum class ApplicationType {
NEST_JS,
MYSQL,
MARIA_DB,
REDIS
REDIS,
H2_DB
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class CreateDockerFileServiceImpl(

ApplicationType.NEST_JS ->
FileContent.getNestJsDockerFileContent(version, application.port, applicationEnv)

ApplicationType.H2_DB ->
FileContent.getH2DBDockerFileContent(version, application.port, applicationEnv)
}
try {
if (!file.exists())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GetApplicationVersionServiceImpl(
ApplicationType.MARIA_DB -> "mariadb" to "10"
ApplicationType.MYSQL -> "mysql" to "8"
ApplicationType.REDIS -> "redis" to "6"
ApplicationType.H2_DB -> "oscarfonts/h2" to "0"
}
val getVersionScript = FileContent.getImageVersionShellScriptContent(baseImageName, minVersion)
return commandPort.executeShellCommandWithResult(getVersionScript)
Expand Down