Skip to content

Commit

Permalink
Merge pull request #652 from gzoller/wip/ash-doc
Browse files Browse the repository at this point in the history
ash support documentation
  • Loading branch information
muuki88 committed Aug 23, 2015
2 parents 85cbd2d + 250ae60 commit e1dfbf1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

realpath () {
(
TARGET_FILE="$1"

cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")

COUNT=0
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
do
TARGET_FILE=$(readlink "$TARGET_FILE")
cd "$(dirname "$TARGET_FILE")"
TARGET_FILE=$(basename "$TARGET_FILE")
COUNT=$(($COUNT + 1))
done

if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then
cd "$TARGET_FILE"
TARGET_FILEPATH=
else
TARGET_FILEPATH=/$TARGET_FILE
fi

echo "$(pwd -P)/$TARGET_FILE"
)
}

real_script_path="$(realpath "$0")"
app_home="$(realpath "$(dirname "$real_script_path")")"
lib_dir="$(realpath "${app_home}/../lib")"

${{template_declares}}

java -classpath $app_classpath $app_mainclass $@
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ import SbtNativePackager.{ Universal, Debian }
*/
object AshScriptPlugin extends AutoPlugin {

val bashTemplate = "bash-template"

override def requires = JavaAppPackaging

//object autoImport extends JavaAppKeys

import JavaAppPackaging.autoImport._

val ashTemplate = "ash-template"

override def projectSettings = Seq(
bashScriptTemplateLocation := (sourceDirectory.value / "templates" / ashTemplate),
makeBashScript <<= (bashScriptTemplateLocation, bashScriptDefines, target in Universal, executableScriptName, sourceDirectory) map makeUniversalAshScript,
bashScriptDefines <<= (Keys.mainClass in (Compile, bashScriptDefines), scriptClasspath in bashScriptDefines, bashScriptExtraDefines, bashScriptConfigLocation) map { (mainClass, cp, extras, config) =>
val hasMain =
Expand Down
21 changes: 21 additions & 0 deletions src/sphinx/formats/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,24 @@ Now let's start adding some Docker commands.
ExecCmd("CMD", "echo", "Hello, World from Docker")
)
Busybox/Ash Support
~~~~~~~~~~~~~~~~~~~

The default shell support for the Java archetype (JavaAppPackaging) is bash, with a Windows
bat file also generated. Busybox is a popular minimal Docker base image that uses ash, a much
more limited shell than bash. The result is that if you build a Docker image for Busybox the
generated bash launch script will likely not work.

Optionally you can use an ash-compatible archetype that derives from JavaAppPacking called
AshScriptPlugin. Enable this by including:

.. code-block:: scala
enablePlugins(AshScriptPlugin)
With this plugin enabled an ash-compatible launch script will be generated in your Docker image.

Just like for JavaAppPackaging you have the option of overriding the default script by supplying
your own src/templates/ash-template file. When overriding the file don't forget to include
${{template_declares}} somewhere to populate $app_classpath $app_mainclass from your sbt project.
You'll likely need these to launch your program.

0 comments on commit e1dfbf1

Please sign in to comment.