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

Demo of doing an equivalent build process without special plugins #105

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jglick
Copy link
Member

@jglick jglick commented Jun 5, 2017

For discussion, not merge. CC @HRMPW

@kuops
Copy link

kuops commented Jun 7, 2017

*************** Installing a local Docker Registry Service for the demo ***************
***************            Please sit tight for a minute                ***************
Unable to find image 'registry:docker-workflow-demo' locally
docker: Error response from daemon: manifest for registry:docker-workflow-demo not found.
See 'docker run --help'.
***************         Docker Registry Service running now             ***************
"docker rmi" requires at least 1 argument(s).
See 'docker rmi --help'.

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

@jglick
Copy link
Member Author

jglick commented Jul 26, 2017

Just a warning which can be ignored.


# Run the test container.
docker run --name=$TEST_CTR --link=$cid:petclinic -v m2repo:/m2repo $TEST_IMG /src/test.sh
docker cp $TEST_CTR:/src/screenshot.jpg .
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is a bit awkward—you would like archiveArtifacts to be able to grab the file straight out of the container. Theoretically there could be a wrapper step which sets a contextual FilePath “workspace” to the container’s / (or some other directory of your choice), allowing nested steps to transparently operate in the container’s filesystem.

Unfortunately the current design of FilePath makes this impossible: it is not an extensible VFS, but rather a final class with two implementations basically selected by a switch: local File, or remote File using Channel calls. There is no place for a plugin to create a completely alternate implementation. And you cannot create a Channel into the container without running slave.jar inside it, which would require it have some JRE installed.

The Kubernetes plugin support for Pipeline, and IIRC the docker-slaves plugin, try to work around this by running a little pod of containers using shared volumes, and running slave.jar inside a designated one. That is a bit heavier weight, though, since it requires running an extra JVM process, and you have to be prepared to designate interesting parts of your “real” container as volumes.

Another trick would be to implement VirtualChannel from scratch to handle selected FilePath callables using completely different implementations, but this would be extremely fragile without a lot of work in core.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now easier using --output in Buildkit.

docker cp $BUILD_CTR:/src/target/petclinic.war app

# Build the actual application image.
docker build -t localhost/examplecorp/spring-petclinic:$BUILD_TAG app
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things are even simpler now with multi-staged docker builds, and this all script can be handled by a single Dockerfile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote elsewhere in the PR, I did actually try to do this with a multistage build, but soon found that I could not mount the Maven repository cache as a volume, which kills performance. Would be possible to prepopulate a cache as a base layer, though this does not easily allow for sharing caches across images. If you have any better ideas, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My experience is that it's way simpler to setup a maven proxy, which will offer high-speed downloads from localhost

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is an option, though you would need to do some work to make the proxy URL be defined as an ENV. For purposes of a demo like this, you would need to set up such a proxy as part of the demo I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not mount the Maven repository cache as a volume

This has since been implemented in Buildkit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Dagger would now be a reasonable choice: dagger/dagger#1677 (comment)

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

Successfully merging this pull request may close these issues.

4 participants