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

Do not use cache when building the image #348

Closed
tecris opened this issue Dec 6, 2015 · 8 comments
Closed

Do not use cache when building the image #348

tecris opened this issue Dec 6, 2015 · 8 comments

Comments

@tecris
Copy link
Contributor

tecris commented Dec 6, 2015

My first post for this project, thank you for sharing
It is correct to assume currently (v 0.13.6) has no flag do disable caching during image building?
(docker build --no-cache=true)
A search for 'cache' in http://ro14nd.de/docker-maven-plugin/ returns no results.
Also no relevant results in issues associated with this project.
Or there is an alternative way to disable caching during image build?

Happy to work on a pull request if this has any value for the project.

@tecris
Copy link
Contributor Author

tecris commented Dec 14, 2015

More explanations:

I am trying this plugin to implement some continuous delivery. Main idea is
that 'mvn verify' will: build images, start and destroy containers. Also
artifacts are uploaded to nexus repository prior to image build(ugly hack to
force mvn deploy during pre-integration-phase :( ).

To build the image I use an external Dockerfile:

...
<image>
  ...
  <build>
    ..
    <assembly>
      <dockerFileDir>web-server</dockerFileDir>
    </assembly>
  </build>
</image>
...

Dockerfile content:

FROM casa.docker/wildfly-mysql:9.0.2

ENV MAVEN_GROUP_ID org.planets
ENV MAVEN_ARTIFACT_ID planets

ENV MAVEN_REPOSITORY_URL 172.17.0.1

RUN wget "http://${MAVEN_REPOSITORY_URL}:8081/service/local/artifact/maven/redirect?r=snapshots&g=${MAVEN_GROUP_ID}&a=${MAVEN_ARTIFACT_ID}&v=LATEST&e=war" \
    -O /opt/jboss/wildfly/standalone/deployments/planets.war

This Dockerfile is as lean as possible, the base image contains all required
configuration and here gets baked only what changes between two consecutive
runs.(in this case is just java code).

With this approach it seems that docker is using the cache always (when building
the docker image) even if the war file retrieved from nexus repository is
different(compared with previous run).

There could also be another solution to all of this. Technically, for what I am
trying to test the maven repository upload is not really necessary as I can
upload the docker image to a docker registry.

@rhuss
Copy link
Collaborator

rhuss commented Jan 19, 2016

You are right, Docker is caching by default any command in a Dockerfile if the line within the Dockerfile doesn't change, so if you don't change the URL for a wget it will be cached by default.

Having a non-caching operational mode is a good idea, I will have a look to your PR in a minute.

Thanks ... and sorry for the delay ..

@kuhnroyal
Copy link
Contributor

The docker.nocache property doesn't seem to be working. The <nocache> works.

@rhuss
Copy link
Collaborator

rhuss commented Feb 16, 2016

Could you try using -Ddocker.nocache=true ?

@kuhnroyal
Copy link
Contributor

That works, I tried to set it directly in the pom which doesn't seem to be supported. I expected it to to work like <docker.autoPull>always</docker.autoPull> for example.

@lojian
Copy link

lojian commented Jun 13, 2018

when will we get it fixed?

@rhuss
Copy link
Collaborator

rhuss commented Jun 13, 2018

Isn't it ? (sorry, I'm alsways a bit lazy with closing issues)

@rhuss
Copy link
Collaborator

rhuss commented Jun 13, 2018

From the docs:

nocache | Don’t use Docker’s build cache. This can be overwritten by setting a system property docker.nocache when running Maven.

thats for a <build> section.

This issue was closed.
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

4 participants