OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
126 stars 90 forks source link

Changing the Dockerfile leads to multiple restarts #1030

Open TrevCraw opened 3 years ago

TrevCraw commented 3 years ago

Modifying or adding lines in the Dockerfile triggers multiple restarts while running devc. On Mac, it appears to only ever restart twice max. On Windows, it seems that the number of restarts after a Dockerfile change increases after each successive change (ie. 4 restarts, then 6, then 10). It could also be related to the content that was changed in the Dockerfile.

The steps below are just an example of what can be changed in the Dockerfile to recreate the issue. It should be reproducible no matter what modification is made to the Dockerfile. 1) Start with the default demo devmode Dockerfile

FROM openliberty/open-liberty:kernel-java8-openj9-ubi

# Add config
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/server.xml /config/
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties /config/
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/liberty-plugin-variable-config.xml /config/configDropins/overrides/

# Add application
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/apps/demo-devmode-maven.war /config/apps/

2) Comment out or remove the first three COPY lines and add COPY --chown=1001:0 target/liberty/wlp/usr/servers/defaultServer /config. Save the Dockerfile and multiple restarts should be triggered.

FROM openliberty/open-liberty:kernel-java8-openj9-ubi

# Add config
COPY --chown=1001:0 target/liberty/wlp/usr/servers/defaultServer /config

# Add application
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/apps/demo-devmode-maven.war /config/apps/

3) Add a new COPY line (create a new file if you need to): COPY src/testFile.txt /config/apps/testFile.txt. Save the Dockerfile and multiple restarts should be triggered (more than before if on Windows).

FROM openliberty/open-liberty:kernel-java8-openj9-ubi

# Add config
COPY --chown=1001:0 target/liberty/wlp/usr/servers/defaultServer /config
COPY --chown=1001:0 src/testFile.txt /configDropins/overrides/testFile.txt

# Add application
COPY --chown=1001:0  target/liberty/wlp/usr/servers/defaultServer/apps/demo-devmode-maven.war /config/apps/
ericglau commented 3 years ago

The above PR resolved the issue on Mac but it still restarts (only) twice on Windows.

ericglau commented 3 years ago

A workaround is to use -DpollingTest when starting dev mode.

ericglau commented 3 years ago

This does not occur with the Dockerfile in our example https://github.com/OpenLiberty/demo-devmode/blob/devc/Dockerfile . It does occur if the Dockerfile has COPY commands for entire directories though.