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

Still confused about how to actually use this to build an image #64

Open
davidmichaelkarr opened this issue Aug 22, 2016 · 0 comments
Open

Comments

@davidmichaelkarr
Copy link

It still feels like there are many missing pieces in this doc. The doc for "dockerPrepare" says barely anything. I can't tell exactly what it's supposed to be doing. I can sort of see the result, but it's missing the files I added, so the final Docker build fails. I'm sure I'm just missing some details that are probably assumptions that I'm not aware of.

My application is a multiproject build, with two WAR projects along with the subproject to build the image. The image subproject depends on the two projects, and a JDBC jar, all three of which I try to add to the context so the Dockerfile can reference them.

The following is the entire build.gradle for the image project:
plugins { id 'com.palantir.docker' version '0.9.0' } apply plugin: 'java' List<String> fileList = ["ordersService.war", "ordersGUI.war", "ojbdc6.jar"].each { "$buildDir/dependencies/" + it } docker { name 'ssorderprocessingdashboard' dockerfile 'src/docker/Dockerfile' files fileList.toArray() } dependencies { runtime project(":ordersService") runtime project(":ordersGUI") runtime "oracle:ojdbc6:11.2.0.3" } task copyDependencies << { configurations.runtime.setTransitive(false).resolvedConfiguration.resolvedArtifacts .each { artifact -> project.copy { from artifact.file into "${buildDir}/dependencies" rename { "${artifact.name}.${artifact.extension}" } } } } build.dependsOn copyDependencies

I haven't yet set task dependencies so the "docker" task will run on build (as that didn't even work, but I'll address that later). For now, I just run the "build" task on the subproject and then the "docker" task on a separate command line.

I verified that after "build", the "${buildDir}/dependencies" dir has my three artifacts properly named.

If it helps, this is my entire Dockerfile:
`FROM tomee:8-jdk-7.0.0-webprofile

ENV SERVICE_HOST_PORT = localhost:8080
ENV DB_HOST = xx
ENV DB_PORT xx
ENV DB_SID xx
ENV DB_USER xx
ENV DB_PASSWORD xx
ENV TOMEE_HOME /usr/local/tomee
ENV env dev

ARG tzoffset

ADD ojdbc6.jar ${TOMEE_HOME}/lib

ADD ordersService.war ${TOMEE_HOME}/webapps/
ADD ordersGUI.war ${TOMEE_HOME}/webapps/

Disable CXF in cxf.properties and cxf-rs.properties.

ADD cxf.properties ${TOMEE_HOME}/conf
ADD cxf-rs.properties ${TOMEE_HOME}/conf

Change host:port that GUI is using to reach the REST service.

If SERVICE_HOST_PORT is set, use that, otherwise use

localhost:8080.

Add DataSource definition to tomee.xml.

ADD tomee.xml.excerpt ${TOMEE_HOME}
ADD system.properties.excerpt ${TOMEE_HOME}
ADD adjustTomEEConfig.sh ${TOMEE_HOME}

Install gettext for envsubst.

ADD aptconf.txt /etc/apt/apt.conf
RUN apt-get update
RUN apt-get install -y gettext

CMD ${TOMEE_HOME}/adjustTomEEConfig.sh $tzoffset; ${TOMEE_HOME}/bin/catalina.sh run`

When I run the "docker" task, this is what I see:
`:ordersImage:dockerClean
:ordersImage:dockerPrepare
:ordersImage:docker
Sending build context to Docker daemon 751 MB
Step 1 : FROM tomee:8-jdk-7.0.0-webprofile
---> 5a2d656682a9
...
Step 11 : ADD ojdbc6.jar ${TOMEE_HOME}/lib
lstat ojdbc6.jar: no such file or directory
:ordersImage:docker FAILED

FAILURE: Build failed with an exception.`

I am just guessing that "${buildDir}/docker" is what "dockerPrepare" produces. The doc doesn't say, and it doesn't say anything about how I can control that, but I think it's a reasonable guess that's what it produces. This directory does not include the "build" directory, or "build/dependencies", which is where the files are stored. I explicitly said to include the files from that directory, so I would assume that "dockerPrepare" would respect that.

I could use some help here.

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

No branches or pull requests

1 participant