consoleme
consoleme copied to clipboard
chore: use multi-stage build
Added multi-stage build, generated image went from 2.83GB to 725MB. I haven't made extended tests to this, but it seems to be working just fine.
Closes #9038
hmm... right, I used yarn
in one of the stages, so it only builds the production version of the UI and that gets copied to the final image. So for developing inside a container we need a full image, node_modules
included. Maybe splitting in two Dockerfiles, one for dev (full image with its 2-point-something GB) another for production (prebuilt UI, minimal pythons deps)?
Will look into the issue with cryptography
module.
@pedrokiefer Would one of the intermediate images be usable as the development image? It would be nice to avoid separate Dockerfiles if we can.
@pedrokiefer Would one of the intermediate images be usable as the development image? It would be nice to avoid separate Dockerfiles if we can.
Not really, but I think it can be done with an env var ENVIRONMENT
. And change the docker-compose to pass this argument:
build:
context: .
args:
- ENVIRONMENT=dev
Would that works for you?
Found the issue with cryptography
, it's only listed in requirements-test.txt
and it wasn't being installed. It probably should be on requirements.txt
too.
I just did a little experimenting and I think this will get us both development and release images from one Dockerfile:
In Dockerfile
, add another intermediate stage called development
(before the final stage) and move the conditional installs to it:
FROM python-builder as development
RUN pip install -r requirements-test.txt
RUN pip install watchdog argh
# Plus whatever we need to make sure Yarn and all the other UI stuff is available
Update docker-compose stanza for the consoleme
service:
services:
consoleme:
build:
context: .
args:
target: development
With this pattern, a docker build .
command will still produce the release image as well as being able to run docker build --target development .
to get the heavier image to run for dev.
@patricksanders used your suggestion, it seems to be working and it's easier to maintain -- I was not happy with all the if's.
Do we need git
installed? I got a warning while testing.
Nice, the Dockerfile and compose changes look good.
I don't think git is a hard requirement. There is some self service wizard functionality that CAN use git, but that's currently a pretty specific use case for Netflix.