score:3
the referenced article is part 2 of a series, where the address of the container is passed into the java program by a script. the script itself is referenced in part 1.
mappings in universal
takes a sequence of (file, string)
tuples. the file is copied to the path specified by the string in the resulting image.
in this case, if there is no file present at basedirectory.value / "docker" / "start"
, then nothing is available to copy, and the resulting is the behavior you describe.
you should create an appropriate start script, as discussed in part 1.
score:3
another option is to make use of the experimental support for docker in sbt-native-packager.
if you remove the docker-related lines from build.sbt, and add a maintainer
setting, you can:
sbt docker:stage
generate a dockerfile and context in target/docker/stage
sbt docker:publishlocal
generate a local image
sbt docker:publish
generate an image and push it remotely
if you want to modify the commands passed to the start script, you can make modifications like this:
bashscriptextradefines := seq(
"cluster_ip=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')",
"addresidual ${cluster_ip}"
)
addresidual
is a function in the start script generated by sbt-native-packager, that adds an extra parameter to the command line arguments for the program.
addjava
is a function that adds an extra parameter to the java binary that runs your program.
your build.sbt
might look like this:
import com.typesafe.sbt.packager.keys._
organization := "com.confabulous"
name := "deva"
version := "0.0.1"
scalaversion := "2.10.3"
scalacoptions := seq("-unchecked", "-deprecation", "-encoding", "utf8", "-language:postfixops")
resolvers ++= seq(
"sonatype releases" at "https://oss.sonatype.org/content/repositories/releases/",
"sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
"typesafe repo" at "http://repo.typesafe.com/typesafe/releases/"
)
librarydependencies ++= seq(
"ch.qos.logback" % "logback-classic" % "1.0.9",
"com.typesafe.akka" % "akka-slf4j_2.10" % "2.3.3",
"com.typesafe.akka" %% "akka-actor" % "2.3.3",
"com.typesafe.akka" %% "akka-remote" % "2.3.3",
"com.typesafe.akka" %% "akka-agent" % "2.3.3",
"com.typesafe.slick" %% "slick" % "2.0.1-rc1",
"org.mozilla" % "rhino" % "1.7r4",
"org.postgresql" % "postgresql" % "9.3-1101-jdbc3",
"org.msgpack" %% "msgpack-scala" % "0.6.8",
"com.livestream" %% "scredis" % "1.1.2",
"com.confabulous" %% "messages" % "0.0.1-snapshot",
"com.confabulous" %% "db" % "0.0.1-snapshot"
)
packagearchetype.java_server
maintainer := "dan ellis <dan@halftreelabs.com>"
more information should be available from the sbt-native-packager documentation. comments are also welcome.
Source: stackoverflow.com
Related Query
- sbt native packager and app writable directory
- Why is sbt-native-packager staging bin/start as a directory instead of a script?
- sbt not generating bin directory when staging or publishing docker + other questions
- Why does Scala sbt update every time I start it from command prompt?
- Why is the message "The global sbt directory is now versioned" in 0.13?
- sbt native packager doesn't create scripts under target/universal/stage/bin
- Multiple project dependencies in SBT native packager
- Environment variable based runtime configuration with sbt native packager
- Sbt native packager not finding SystemdPlugin
- Why SBT creates "default" directory when i use publishLocal command?
- Why spark blas use f2jBLAS instead of native BLAS for level 1 routines?
- Adding artifact to play project using SBT - Native Packager Plugin
- Debug Docker application built with SBT Native Packager
- How do I get SBT staging directory at build time?
- SBT Native Packager - How to retrieve libraryDependencies and store them as part of the package?
- creating rpm using sbt native packager for scala play app
- SBT Native Packager SystemVLoader not generating SystemLoader scripts
- Config file include issue with sbt native packager
- Run start script generation from SBT task
- How to deploy a Scala Play framework API using the SBT native packager
- Disable user/group create/delete as part of sbt native packager rpm install
- simplify settings for deb only build with sbt native packager
- Conditional JavaAgent Command for SBT Native Packager
- SBT native packager does not copy file to Docker image
- SBT Native Packager change output location of ZIP
- Setting up play new instead of sbt new to start a project
- Why is Scala JavaFX application slowing down when run from .jar instead of using sbt run?
- Stop SBT Native Packager writing to /etc/<app>
- SBT Native Packager Not Including Entrypoint
- Packaging Play application for windows using Native sbt Packager
More Query from same tag
- How can I skip a "should" block/fragment in specs2?
- scala syntax to match on multiple case class types without decomposing the case class
- Creating Spark Dataframes from regular classes
- How can I serialize Sangria responses with json4s and Akka HTTP?
- How to install ReactiveMongo on play 2.4?
- How does memory management for Scala collections work?
- defining a simple implicit Arbitary
- Building Flex component inside SBT
- not able to move mouse and capture gesture using Leapmotion controller in scala
- What does ?~> meaning in the scala programming language?
- scala: list of dates to list of ranges
- HackerRank Array Of N Elements compilation error (Scala)
- scala parameterised merge sort - confusing error message
- Scala Lift: Multiple Comet Actors on same page
- Spark scala join RDD between 2 datasets
- Which JVM language doesn't have type erasure?
- Why does scala sortWith function is taking Predicate as input
- How to put an ID from a scala template into an AJAX call?
- How varargs like Int*, String* implemented in Scala?
- List of uneven data to dataframe
- Scala macros: how to pass additional arguments
- Jasmine sbt plugin not executing tests
- Alternative ways to display Scalatest results
- Why is IntelliJ highlighting errors in one project, but not another?
- Write to AWS SQS queue using Spark
- What are the differences between Either and Option?
- Play2.4 Scala download pdf file on android device
- How to change Ammonite, coursier cache location?
- How to realize maven-like dependency shading using sbt-proguard?
- Should I upgrade to Intellij Ultimate Edition?