Q:

sbt native packager dockerCommands copy

Searching on the internet, and here, but couldn't find answer that solves my problem.  
My problem is I want to create a docker image with some custom sql scripts copied from local file system to the docker image.  
Directory structure (a multiple module projects) is
my_sbt
    + my_app
        - build.sbt ...
    + database
        - build.sbt 
        + scripts
            - ... several sql scripts ...

database/build.sbt contains dockerCommands 
dockerCommands := Seq(
  Cmd("FROM", "postgres:9.5"),
  Cmd("EXPOSE", "5432"),
  Cmd("COPY", (baseDirectory.value / "database" / "scripts" / "a.sql").toPath.toAbsolutePath.toString, "/docker-entrypoint-initdb.d/a.sql")
)

Image can be created successfully if without COPY Cmd (i.e. docker run -d --rm -p 5432:5432 <docker image> starts container, and docker exec -it <container id> bash can bash to container and validate processing is up running by ps -ef in container bash).  However, adding COPY statement to dockerCommands crashes the build process sbt docker:publishLocal with error java.lang. RuntimeException: Nonzero exit value: 1
java.lang. RuntimeException: Nonzero exit value: 1
    at com.typesafe.sbt.packager.docker. DockerPlugin$.publishLocalDocker(DockerPlugin.scala:335)
    at com.typesafe.sbt.packager.docker. DockerPlugin$$anonfun$projectSettings$22.apply(DockerPlugin.scala:119)
    at com.typesafe.sbt.packager.docker. DockerPlugin$$anonfun$projectSettings$22.apply(DockerPlugin.scala:117)
...

Run sbt with -d sbt -d docker:publishLocal doesn't help as it still throws Nonzero exit value: 1, which doesn't help at all.  
What is the correct way to refer to the local scripts and copy it to docker image? 
Thanks
EDIT: 

Just notice that sbt native packager seems to strip of the leading root path i.e. '/'.  Any reason why it does so?  And how to prevent leading / from stripping off?  
[info] Step 3/3 : COPY /path/to/database/scripts/users.sql /docker-entrypoint-initdb.d/users.sql
[error] lstat path/to/database/scripts/users.sql: no such file or directory

A:

The link at https://serverfault.com/questions/666149/docker-copy-issue-no-such-file-or-directory/666154#666154 solves my problem.  
Basically the problem comes from docker's indirect way of associating local files to docker container.  

sbt native packager copies local files to target/docker/stage based on mappings in Universal section.  For instance, below code snippet copies a.sql to target/docker/stage/opt/docker/scripts under project directory
mappings in Universal := {
  (mappings in Universal).value :+
  (file(s"${baseDirectory.value}/scripts/a.sql") -> "scripts/a.sql") 
}

sbt native packager then copies files located at target/docker/stage/ to docker container based on dockerCommands's Cmd("COPY", "/opt/docker/scripts/a.sql", "/docker-entrypoint-initdb.d")

So The <src> path must be inside the context of the build; ... where the context is actually starting from target/docker/stage/. 

