2016-11-04 84 views

回答

1

我不得不把它添加到我的build.sbtjvmSettings部分:

javaOptions in Universal ++= Seq("-jvm-debug 5005"), 

此外,在docker-compose.yml調試端口必須打開:

services: 
    myApp:  
    image: registry.gitlab.com/bullbytes/myApp:latest 
    ports: 
     # Debugging port 
     - "5005:5005" 

對於某些情況,th是我build.sbt的簡化,但完整版本:

scalaVersion in ThisBuild := "2.11.8" 
// Whether we are in production or development mode 
val isDevMode = true 

lazy val root = project.in(file(".")). 
    aggregate(client, server). 
    settings(
    name := "My app root" 
) 

// We can run this project by calling appJS/run and appJVM/run. Enter `projects` in SBT to see the name of all projects 
lazy val app = crossProject.in(file("./app")). 
    settings(
    name := "my application" 
). 
    jvmSettings(
    libraryDependencies ++= /* my server-side dependencies*/, 
    // Enable debugging 
    javaOptions in Universal ++= Seq(
     "-jvm-debug 5005" 
    ), 
    imageNames in docker := { 
     Seq(
     ImageName(
      repository = "registry.gitlab.com/bullbytes/myApp", 
      tag = Some("my tag") 
     ) 
    ) 
    }, 
    dockerfile in docker := { 
     val appDir = stage.value 
     val targetDir = "/app" 
     new Dockerfile { 
     from("java:8-jre") 
     entryPoint(s"$targetDir/bin/${executableScriptName.value}") 
     copy(appDir, targetDir) 
     expose(8080) 
     } 
    } 

    /** 
     * We enable JavaAppPackaging to create a jar. Also, this gives us access to the variables stage and executableScriptName. 
     * Issuing "appJVM/docker" in SBT creates a Docker image from that jar. 
     */ 
).enablePlugins(JavaAppPackaging, sbtdocker.DockerPlugin). 
    jsSettings(

    libraryDependencies ++= /* my client-side Scala.js dependencies*/, 
    jsDependencies ++= /* my client-side JavaScript dependencies*/, 

    // Include the JavaScript dependencies 
    skip in packageJSDependencies := false, 

    // Use the faster Node.js instead of Rhino. Get Node.js from here: https://nodejs.org 
    //scalaJSUseRhino in Global := false 

    // Regardless of whether we optimize the created JavaScript fast or fully, produce a .js file with the same name. 
    // This way, we don't have to adapt the name of the script to load at the client when we switch optimize modes 
    artifactPath in Compile in fastOptJS := (crossTarget in fastOptJS).value/((moduleName in fastOptJS).value + ".js"), 
    artifactPath in Compile in fullOptJS := (crossTarget in fullOptJS).value/((moduleName in fullOptJS).value + ".js"), 

    persistLauncher in Compile := true, 
    persistLauncher in Test := false 
) 

// We need to define the subprojects. Note that the names of these vals do not affect how you run the subprojects: 
// It will be `<nameOfCrossProject>JS/run` and `<nameOfCrossProject>JVM/run`, irrespective of how these vals are named 
lazy val client = app.js.settings() 

/** 
    * Adds the compiled JavaScript to the server's resources since the server sends the JavaScript to the client 
    * 
    * @return a sequence of files that consists of our generated JavaScript file. Wrapped in a setting task for SBT 
    */ 
def addJavaScriptToServerResources() = { 
    if (isDevMode) { 
    (resources in Compile) += (fastOptJS in(client, Compile)).value.data 
    } else { 
    (resources in Compile) += (fullOptJS in(client, Compile)).value.data 
    } 
} 
def addJSDependenciesToServerResources() = { 
    (resources in Compile) += (packageMinifiedJSDependencies in(client, Compile)).value 
} 
lazy val server = app.jvm.settings(
    addJavaScriptToServerResources(), 
    addJSDependenciesToServerResources(), 

    /* 
    Setting 'persistLauncher' to true generates a small JavaScript launcher that calls the main method in the client. 
    The server sends the launcher script to the client. 
    See also: https://www.scala-js.org/tutorial/basic/#automatically-creating-a-launcher 
    */ 
    (resources in Compile) += (packageScalaJSLauncher in(client, Compile)).value.data 
) 

這裏是由SBT本地打包生成的啓動腳本一些更多的選擇:link

相關問題