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

Docker Build Fails #39

Closed
jd-carroll opened this issue Apr 17, 2016 · 8 comments
Closed

Docker Build Fails #39

jd-carroll opened this issue Apr 17, 2016 · 8 comments

Comments

@jd-carroll
Copy link
Contributor

jd-carroll commented Apr 17, 2016

When running docker build locally, the build fails with:

$ docker build -f src/main/docker/dev/Dockerfile .
Sending build context to Docker daemon 116.8 MB
Step 1 : FROM alpine:3.3
 ---> d7a513a663c1
...
(25/25) Installing openjdk8 (8.77.03-r0)
Executing busybox-1.24.1-r7.trigger
Executing ca-certificates-20160104-r2.trigger
Executing java-common-0.1-r0.trigger
OK: 141 MiB in 36 packages
 ---> b0218fb4744b
Removing intermediate container 749ba252f4c2
Step 4 : ENV SPRING_PROFILES dev
 ---> Running in d1584e159d60
 ---> af1a04d2bb47
Step 5 : ADD *.war /jhipster-registry.war
No source files were specified

Issue: The build fails because it cannot find the target/jhipster-registry-0.0.1-SNAPSHOT.war file.

Note: Because the build fails, docker does not successfully tag the built image (since it is still technically an intermediate container). So running docker images produces

$ docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
<none>                             <none>              af1a04d2bb47        10 minutes ago      145.5 MB

Any attempt to run this image will result in:

$ docker run af1a04d2bb47
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: No command specified.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

This is because the Dockerfile does not set the default CMD until Step 9.

Steps to Reproduce:

  • Install the latest version of Docker Toolbox (v1.11.0)
  • Create a new local copy of the registry
    git clone https://github.com/jhipster/jhipster-registry && cd jhipster-registry
  • Build the registry
    mvn -Pdev package
  • Build the docker image
    docker build -f src/main/docker/dev/Dockerfile .

OS: Windows 7 Pro

@jd-carroll
Copy link
Contributor Author

If I change the Dockerfile to:

ADD target/*.war /jhipster-registry.war

It will find the file and appears to work.

@pascalgrimaud
Copy link
Member

Yes it's normal, see #13
You are supposed to run: mvn package docker:build and not build directly with the Dockerfile

The docker plugin will copy all necessary files under target/docker/ before running docker build

@pascalgrimaud
Copy link
Member

One thing too: by building locally, it will generate a "dev" tag for the image. It will not be the same used in Docker Compose sub generator

@jdubois
Copy link
Member

jdubois commented Apr 18, 2016

Yes @pascalgrimaud is right so I'm closing this

@jdubois jdubois closed this as completed Apr 18, 2016
@ramanrai1981
Copy link

ramanrai1981 commented Jun 25, 2017

Hi Mr. Jdubois,
I am setting up my application eofficecassandra and (it is not jhipster-registry based) with Jenkins-ci with DockerHub.
How to solve ?

docker logo

Search
Dashboard
Explore
Organizations
Create
Create Repository
Create Automated Build
Create Organization
ramanrai1981
My Profile
Documentation
Help
Settings
Log out
PUBLIC | AUTOMATED BUILD
ramanrai1981/eofficecassandra
Last pushed: never
Repo Info
Tags
Dockerfile
Build Details
Build Settings
Collaborators
Webhooks
Settings
Build failed: No source files were specified
SourceRef
Dockerfile Location
Docker Tag
Build Created
UTC
master
/src/main/docker/
latest
25 minutes ago
2017-06-25T04:47:16.149Z
Build Code
bsltpdozvwmhj8uxou9ntsd
README
eoffice
This application was generated using JHipster 4.0.7, you can find documentation and help at https://jhipster.github.io/documentation-archive/v4.0.7.

Development
Before you can build this project, you must install and configure the following dependencies on your machine:

Node.js: We use Node to run a development web server and build the project.
Depending on your system, you can install Node either from source or as a pre-packaged bundle.
Yarn: We use Yarn to manage Node dependencies.
Depending on your system, you can install Yarn either from source or as a pre-packaged bundle.
After installing Node, you should be able to run the following command to install development tools.
You will only need to run this command when dependencies change in package.json.

yarn install
We use Gulp as our build system. Install the Gulp command-line tool globally with:

yarn global add gulp-cli
Run the following commands in two separate terminals to create a blissful development experience where your browser
auto-refreshes when files change on your hard drive.

./mvnw
gulp
Bower is used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by
specifying a newer version in bower.json. You can also run bower update and bower install to manage dependencies.
Add the -h flag on any command to see how you can use it. For example, bower update -h.

For further instructions on how to develop with JHipster, have a look at Using JHipster in development.

Building for production
To optimize the eoffice application for production, run:

./mvnw -Pprod clean package
This will concatenate and minify the client CSS and JavaScript files. It will also modify index.html so it references these new files.
To ensure everything worked, run:

java -jar target/*.war
Then navigate to http://localhost:8080 in your browser.

Refer to Using JHipster in production for more details.

Testing
To launch your application's tests, run:

./mvnw clean test
Client tests
Unit tests are run by Karma and written with Jasmine. They're located in src/test/javascript/ and can be run with:

gulp test
Other tests
Performance tests are run by Gatling and written in Scala. They're located in src/test/gatling and can be run with:

./mvnw gatling:execute
For more information, refer to the Running tests page.

Using Docker to simplify development (optional)
You can use Docker to improve your JHipster development experience. A number of docker-compose configuration are available in the src/main/docker folder to launch required third party services.
For example, to start a cassandra database in a docker container, run:

docker-compose -f src/main/docker/cassandra.yml up -d
To stop it and remove the container, run:

docker-compose -f src/main/docker/cassandra.yml down
You can also fully dockerize your application and all the services that it depends on.
To achieve this, first build a docker image of your app by running:

./mvnw package -Pprod docker:build
Then run:

docker-compose -f src/main/docker/app.yml up -d
For more information refer to Using Docker and Docker-Compose, this page also contains information on the docker-compose sub-generator (yo jhipster:docker-compose), which is able to generate docker configurations for one or several JHipster applications.

Continuous Integration (optional)
To configure CI for your project, run the ci-cd sub-generator (yo jhipster:ci-cd), this will let you generate configuration files for a number of Continuous Integration systems. Consult the Setting up Continuous Integration page for more information.

Dockerfile
FROM openjdk:8-jre-alpine

ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
JHIPSTER_SLEEP=0

add directly the war

ADD *.war /app.war

VOLUME /tmp
EXPOSE 8080
CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." &&
sleep ${JHIPSTER_SLEEP} &&
java -Djava.security.egd=file:/dev/./urandom -jar /app.war
Logs
Building in Docker Cloud's infrastructure...
Cloning into '.'...

Checking out files: 4% (9071/184354)
Checking out files: 5% (9218/184354)
Checking out files: 6% (11062/184354)
Checking out files: 7% (12905/184354)
Checking out files: 8% (14749/184354)
Checking out files: 9% (16592/184354)
Checking out files: 10% (18436/184354)
Checking out files: 11% (20279/184354)
Checking out files: 11% (20351/184354)
Checking out files: 12% (22123/184354)
Checking out files: 13% (23967/184354)
Checking out files: 14% (25810/184354)
Checking out files: 15% (27654/184354)
Checking out files: 16% (29497/184354)
Checking out files: 16% (30649/184354)
Checking out files: 17% (31341/184354)
Checking out files: 18% (33184/184354)
Checking out files: 19% (35028/184354)
Checking out files: 20% (36871/184354)
Checking out files: 21% (38715/184354)
Checking out files: 22% (40558/184354)
Checking out files: 22% (41161/184354)
Checking out files: 23% (42402/184354)
Checking out files: 24% (44245/184354)
Checking out files: 25% (46089/184354)
Checking out files: 26% (47933/184354)
Checking out files: 27% (49776/184354)
Checking out files: 28% (51620/184354)
Checking out files: 28% (51858/184354)
Checking out files: 29% (53463/184354)
Checking out files: 30% (55307/184354)
Checking out files: 31% (57150/184354)
Checking out files: 32% (58994/184354)
Checking out files: 33% (60837/184354)
Checking out files: 33% (61700/184354)
Checking out files: 34% (62681/184354)
Checking out files: 35% (64524/184354)
Checking out files: 36% (66368/184354)
Checking out files: 37% (68211/184354)
Checking out files: 38% (70055/184354)
Checking out files: 38% (70164/184354)
Checking out files: 39% (71899/184354)
Checking out files: 40% (73742/184354)
Checking out files: 41% (75586/184354)
Checking out files: 42% (77429/184354)
Checking out files: 42% (78438/184354)
Checking out files: 43% (79273/184354)
Checking out files: 44% (81116/184354)
Checking out files: 45% (82960/184354)
Checking out files: 46% (84803/184354)
Checking out files: 47% (86647/184354)
Checking out files: 47% (86893/184354)
Checking out files: 48% (88490/184354)
Checking out files: 49% (90334/184354)
Checking out files: 50% (92177/184354)
Checking out files: 51% (94021/184354)
Checking out files: 51% (95444/184354)
Checking out files: 52% (95865/184354)
Checking out files: 53% (97708/184354)
Checking out files: 54% (99552/184354)
Checking out files: 55% (101395/184354)
Checking out files: 56% (103239/184354)
Checking out files: 56% (104282/184354)
Checking out files: 57% (105082/184354)
Checking out files: 57% (105807/184354)
Checking out files: 58% (106926/184354)
Checking out files: 59% (108769/184354)
Checking out files: 60% (110613/184354)
Checking out files: 61% (112456/184354)
Checking out files: 61% (112868/184354)
Checking out files: 62% (114300/184354)
Checking out files: 63% (116144/184354)
Checking out files: 64% (117987/184354)
Checking out files: 65% (119831/184354)
Checking out files: 66% (121674/184354)
Checking out files: 66% (122118/184354)
Checking out files: 67% (123518/184354)
Checking out files: 68% (125361/184354)
Checking out files: 69% (127205/184354)
Checking out files: 70% (129048/184354)
Checking out files: 71% (130892/184354)
Checking out files: 71% (131324/184354)
Checking out files: 72% (132735/184354)
Checking out files: 73% (134579/184354)
Checking out files: 73% (135106/184354)
Checking out files: 74% (136422/184354)
Checking out files: 75% (138266/184354)
Checking out files: 76% (140110/184354)
Checking out files: 76% (140182/184354)
Checking out files: 77% (141953/184354)
Checking out files: 78% (143797/184354)
Checking out files: 79% (145640/184354)
Checking out files: 80% (147484/184354)
Checking out files: 81% (149327/184354)
Checking out files: 81% (149450/184354)
Checking out files: 82% (151171/184354)
Checking out files: 83% (153014/184354)
Checking out files: 84% (154858/184354)
Checking out files: 85% (156701/184354)
Checking out files: 86% (158545/184354)
Checking out files: 86% (159327/184354)
Checking out files: 87% (160388/184354)
Checking out files: 88% (162232/184354)
Checking out files: 89% (164076/184354)
Checking out files: 90% (165919/184354)
Checking out files: 90% (166137/184354)
Checking out files: 91% (167763/184354)
Checking out files: 91% (168193/184354)
Checking out files: 92% (169606/184354)
Checking out files: 93% (171450/184354)
Checking out files: 93% (172101/184354)
Checking out files: 94% (173293/184354)
Checking out files: 95% (175137/184354)
Checking out files: 96% (176980/184354)
Checking out files: 97% (178824/184354)
Checking out files: 98% (180667/184354)
Checking out files: 98% (181766/184354)
Checking out files: 99% (182511/184354)
Checking out files: 100% (184354/184354)
Checking out files: 100% (184354/184354), done.

KernelVersion: 4.4.0-79-generic
Arch: amd64
BuildTime: 2017-03-28T19:26:53.326478373+00:00
ApiVersion: 1.27
Version: 17.03.1-ee-2
MinAPIVersion: 1.12
GitCommit: ad495cb
Os: linux
GoVersion: go1.7.5
Starting build of index.docker.io/ramanrai1981/eofficecassandra:latest...
Step 1/6 : FROM openjdk:8-jre-alpine

---> 038cdcbf73ff

Step 2/6 : ENV SPRING_OUTPUT_ANSI_ENABLED ALWAYS JHIPSTER_SLEEP 0

---> Running in de5d7df63a7f

---> 56a8bf986e72

Removing intermediate container de5d7df63a7f

Step 3/6 : ADD *.war /app.war

No source files were specified

@jdubois
Copy link
Member

jdubois commented Jun 25, 2017

I'm sorry but you need to open a ticket and follow the guidelines.

@SkyNetDZ
Copy link

SkyNetDZ commented May 29, 2018

I have a same problem with docker to get image from maven plugin ...
`
[INFO] Building image test-back:latest
Step 1/7 : FROM java:openjdk-8-jre-alpine

---> fdc893b19a14
Step 2/7 : VOLUME /tmp

---> Using cache
---> a2c5e16b4e90
Step 3/7 : RUN sh -c 'touch /test-api.jar'

---> Using cache
---> 085407d9d42c
Step 4/7 : ENV JAVA_OPTS=""

---> Using cache
---> a592e0f4964f
Step 5/7 : RUN apk add --update ttf-dejavu && rm -rf /var/cache/apk/*

---> Using cache
---> 699adbac7816
Step 6/7 : ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /test-api.jar"]

---> Using cache
---> 9ed832b0e5a4
Step 7/7 : ADD target/*.jar /test-api.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:09 min
[INFO] Finished at: 2018-05-29T10:37:09+02:00
[INFO] Final Memory: 64M/481M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.3:build (build-and-tag) on project test-back: Exception caught: ADD failed: no source files were specified -> [Help 1]`

@jdubois
Copy link
Member

jdubois commented May 29, 2018

Same comment as above, if you have an issue please follow the guidelines and open a new issue - this is old ticket from 2016, you issue is probably different

@jhipster jhipster locked as resolved and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants