Skip to content

Instantly share code, notes, and snippets.

@joesan
Last active January 2, 2023 10:11
Show Gist options
  • Save joesan/fb789a9e25b3a989cc6b7130036e1a47 to your computer and use it in GitHub Desktop.
Save joesan/fb789a9e25b3a989cc6b7130036e1a47 to your computer and use it in GitHub Desktop.
Scala script from within a Bash
#!/bin/sh
exec scala "$0" "$@"
!#
/***
scalaVersion := "2.11.11"
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.3.1"
)
*/
import java.io.File
import com.typesafe.config.{Config, ConfigFactory}
import sys.process._
case class JavaConfig(jreVersion: Int)
case class PythonConfig(pythVersion: Int)
object DockerBuild {
def main(args: Array[String]) {
println("My mission is to build Docker base images!")
buildImage(loadConfig("application.conf"))
}
def loadConfig(cfgFileName: String): Config = {
ConfigFactory.parseFile(new File(s"conf/$cfgFileName")).resolve()
}
def buildImage(cfg: Config) = {
buildJavaImages(JavaConfig(jreVersion = cfg.getInt("docker.build.java.version")))
}
def buildJavaImages(javaCfg: JavaConfig) = {
s"docker build --build-arg JRE_VERSION=${javaCfg.jreVersion} --tag=jothi/jre-alpine java/" !
}
}
DockerBuild.main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment