Where to COPY my app files, etc when jenkins pipeline docker container runtime settings are overriding my Dockerfile settings?
I'm trying to setup a pipeline where a container is built, run, and appropriate tests run in the container, all during the job. The challenge I'm hitting is that jenkins seems to be overriding my WORKDIR and USER that I specify in my Dockerfile. My Dockerfile looks like this:
# Create `app` group and user since the base nodesource image
In Jenkins output I'm seeing that it's building the image as I would expect, but then it's overriding the WORKDIR and USER settings I've specified in my Dockerfile when it runs 'docker run' to create a container:
The issue as I see it is jenkins overriding a lot of my Dockerfile settings:
*my WORKDIR in Dockerfile will be overridden by jenkins during runtime
*The COPY directive in the Dockerfile isn't going to put my application files where Jenkins will later override the WORKDIR to point to
*jenkins is going to override the user to 'jenkins'
The result of course is my application tests can't run properly because the env isn't as specified in the Dockerfile.
I have tried passing in the relevant arguments -w and -u on the .inside line, just like I'm doing with the --net arg, but jenkins simply appends them to what it already thinks it should be doing, so I end up with my -w as well as jenkins -w, etc, which of course isn't helping.
It's possible I'm not approaching this in the way the docker functionality inside jenkins pipelines was intended to be used. How are folks working around the issues I'm hitting?
I've had a hard time finding detailed documentation that covers the docker.build and .inside methods in detail, as well as best practices for using them.