Last active
July 2, 2019 11:30
-
-
Save JamesJJ/4f83ba35c9f4100f1b3024de8867823d to your computer and use it in GitHub Desktop.
build.sbt snippet for building with https://www.scala-sbt.org/sbt-native-packager/formats/docker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
project/sbt-native-packager.sbt: | |
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.23") | |
*/ | |
// ... | |
// BASE IMAGE | |
dockerBaseImage := "openjdk:8-jre-slim-stretch" | |
// SBT DOCKER BUILD PLUGIN CONFIGURATION | |
dockerVersion := Some(DockerVersion(18, 6, 3, Some("ce"))) | |
// IMAGE LABELS | |
dockerLabels := Map("version" -> version.value, | |
"base_image" -> dockerBaseImage.value, | |
"owner_team" -> "PUT_YOUR_TEAM_NAME_HERE", | |
"build_id" -> Option(System.getProperty("build_id")).getOrElse("NA") | |
) | |
// IMAGE ENV | |
dockerEnvVars := Map("SERVICE_NAME" -> "xxx", | |
"SERVICE_TAGS" -> "yyy,zzz" | |
) | |
// APPLY SECURITY UPDATES | |
lazy val serviceUserGroup = Def.setting( | |
(daemonUserUid in Docker).value.getOrElse((daemonUser in Docker).value) | |
++ ":" ++ (daemonGroupGid in Docker).value.getOrElse((daemonGroup in Docker).value)) | |
dockerCommands := dockerCommands.value ++ Seq( | |
Cmd("USER", "root"), | |
Cmd("RUN", | |
"if test -f /etc/alpine-release; then apk upgrade --no-cache -v; apk add --no-cache bash; fi;" | |
++ "if test -f /etc/debian_version; then apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* ; fi;" | |
), | |
Cmd("USER", serviceUserGroup.value) | |
) | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment