Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt docker:stage fails but sbt docker:publishLocal works #1006

Closed
joesan opened this issue Jul 5, 2017 · 4 comments
Closed

sbt docker:stage fails but sbt docker:publishLocal works #1006

joesan opened this issue Jul 5, 2017 · 4 comments
Labels

Comments

@joesan
Copy link

joesan commented Jul 5, 2017

Expected behaviour

sbt docker:stage produced Dockerfile should build when doing docker build ...

Actual behaviour

The following is what happens when issuing docker build command

Joes-Macboob:project-1 jjoeothi$ docker build -t myDockerImage  target/docker/
Sending build context to Docker daemon 60.41 MB
Step 1/7 : FROM anapsix/alpine-java:8_server-jre_unlimited
 ---> f4011286922b
Step 2/7 : WORKDIR /opt/docker
 ---> Using cache
 ---> 78d1bdb9c89f
Step 3/7 : ADD opt /opt
lstat opt: no such file or directory

But when I run sbt docker:publishLocal, I can see that the image is published successfully to my local docker repository! So here is the output of sbt docker:publishLocal

[info] Sending build context to Docker daemon 60.41 MB
[info] Step 1/7 : FROM anapsix/alpine-java:8_server-jre_unlimited
[info]  ---> f4011286922b
[info] Step 2/7 : WORKDIR /opt/docker
[info]  ---> Using cache
[info]  ---> 78d1bdb9c89f
[info] Step 3/7 : ADD opt /opt
[info]  ---> 7d14a7f40eb3
[info] Removing intermediate container e01059e75ae4
[info] Step 4/7 : RUN chown -R daemon:daemon .
[info]  ---> Running in 6ddd64325fa4
[info]  ---> 82180d099e26
[info] Removing intermediate container 6ddd64325fa4
[info] Step 5/7 : USER daemon
[info]  ---> Running in 22385110b51b
[info]  ---> 12e080b87000
[info] Removing intermediate container 22385110b51b
[info] Step 6/7 : ENTRYPOINT bin/esp-kubernetes-project-1
[info]  ---> Running in ec44b80fdfc4
[info]  ---> 82f62b460f5a
[info] Removing intermediate container ec44b80fdfc4
[info] Step 7/7 : CMD
[info]  ---> Running in b0001695cf6e
[info]  ---> 7d962f50e73d
[info] Removing intermediate container b0001695cf6e
[info] Successfully built 7d962f50e73d

Information

  • What sbt-native-packager are you using - version 1.2.0
  • What sbt version - 0.13.11, Scala version - 2.11.11
  • What is your build system- MacOS
  • What package are you building - docker
  • What version has your build tool - docker version is Docker version 17.03.1-ce, build c6d412e
  • What is your target system - anapsix/alpine-java:8_server-jre_unlimited
@muuki88 muuki88 added the docker label Jul 9, 2017
@muuki88
Copy link
Contributor

muuki88 commented Jul 9, 2017

Thanks for you bug report and sorry for the late reply.

IIRC the dockerfile is placed in two places. In which directory are you executing your docker build command? I guess if you go one level up or down, it will work.

I haven't found the pull request/commit yet where this was introduced. There was a reason plausible for docker at that time (at least it sounded plausible). However this has led to too much confusion and we should remove these double-dockerfile output ( if this is the actual root cause for your issue ).

@joesan
Copy link
Author

joesan commented Jul 9, 2017

So as you can see from my post, I'm executing the docker:stage command in the directory where the Dockerfile is written - which is the target/docker directory. Could you please let me know where the other Dockerfile is being written?

@muuki88
Copy link
Contributor

muuki88 commented Jul 9, 2017

When you run docker:stage you'll get a new folder target/docker. When you take a look at what's inside you'll see the following structur (this was generated with the test-project-docker from native-packager):

tree target/docker
target/docker/
├── Dockerfile
└── stage
    ├── Dockerfile
    └── opt
        └── docker
            ├── bin
            │   ├── docker-test
            │   └── docker-test.bat
            └── lib
                ├── docker-test.docker-test-0.1.0.jar
                └── org.scala-lang.scala-library-2.10.6.jar

As you can see there are two Dockerfiles. If you take a look inside the Dockerfile you'll see the line

ADD opt /opt

which assumes an opt directory in the current working directory. This is only the case for the docker file inside the stage folder. The Dockerfile one level higher is an artifact that should be removed from the entire build process.

@muuki88
Copy link
Contributor

muuki88 commented Nov 1, 2017

@joesan any updates on this? Or can I close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants