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

Introduce a CI/CD-friendly Dockerfile #59

Merged
merged 5 commits into from
Apr 11, 2018
Merged

Conversation

kocolosk
Copy link
Member

This dev image configuration is modeled after the 2.1.1 Dockerfile with a few modifications useful for day-to-day development:

  • The Dockerfile builds from git rather than the official source releases. The build is configurable using the following build-args:
clone_url (default: https://gitbox.apache.org/repos/asf/couchdb.git)
checkout_branch (default: master)
configure_options (default: <blank>)

The configure_options are passed directly to ./configure and can be used to e.g. --disable-docs or --disable-fauxton:

docker build --build-arg checkout_branch=my-cool-feature dev/
  • We take advantage of multi-stage builds to create a series of layers that optimize build time without inflating the final image size. In normal development the layers that install runtime and build dependencies will be cached, and the build will start by updating and configuring the existing git clone.

This work includes the changes proposed in #50 and #57. It moves the existing "cluster-in-a-box" Dockerfile to dev-cluster; I'd be curious to see if anyone uses that approach. Personally I think we should continue to refine and harden the Helm chart providing a Kubernetes StatefulSet and refer folks there instead.

@kocolosk kocolosk changed the title Introduce a development-friendly Dockerfil Introduce a development-friendly Dockerfile Jan 16, 2018
@kocolosk
Copy link
Member Author

kocolosk commented Jan 16, 2018

I did not manage to resolve #58 with this work, so --build-arg configure_options="--disable-docs" is required to produce a final image successfully.

#58 is now addressed by c6ec4b4

@kocolosk kocolosk changed the title Introduce a development-friendly Dockerfile Introduce a CI/CD-friendly Dockerfile Jan 16, 2018
@kocolosk
Copy link
Member Author

One detail I realized while chatting with @rnewson and @chewbranca on IRC about this is that the source code is removed entirely from the final image because it lives in one of the build layers, so that messes up the use case where one could imagine a developer doing docker run with this image directly for development. Of course, keeping the source code in the final image is also problematic for production systems. Hence I updated the title to refer to this as a "CI/CD-friendly image".

@wohali
Copy link
Member

wohali commented Jan 17, 2018

Thanks @kocolosk , I will look at these later in the week.

@kocolosk
Copy link
Member Author

Cool take your time, half of this I only learned about in the last 36 hours so it’s entirely possible that this is a moving target. Eager for any feedback towards that end.

texlive-fonts-recommended \
texlive-latex-extra \
&& curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo 'deb https://deb.nodesource.com/node_6.x jessie main' > /etc/apt/sources.list.d/nodesource.list \
Copy link
Member

Choose a reason for hiding this comment

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

Node 6 is end of life now. Could you update this to use node 8 which is the current LTS.

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly. That was a straight copy/paste from the old Dockerfile but happy to upgrade it as part of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

@garrensmith The README in Fauxton still says we require "at least Node 6 and npm 3", is that no longer true? If not we'll need to change the build for non-dev instances, too.

Copy link
Member

Choose a reason for hiding this comment

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

Its fine to use node 6. I recall you asking me to try to use node 6 for as long as possible so I have intentionally made sure it still works on 6. But since this is a dev image it would be better if we were using a more recent version of Node.

Copy link
Member Author

Choose a reason for hiding this comment

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

@garrensmith out of curiosity where do I go to find the node release cycle? I tried https://github.com/nodejs/Release but I couldn't match it up with your comment here.

Copy link
Member

Choose a reason for hiding this comment

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

@kocolosk my guess is that he means it moves to maintenance LTS in a couple of months, i.e. no more improvements other than security patches...and it's probably fair to say that it's not getting a lot of actual changes these days, either... ;)

dev/Dockerfile Outdated

MAINTAINER CouchDB Developers [email protected]
LABEL maintainer="CouchDB Developers <[email protected]>"
Copy link
Member

Choose a reason for hiding this comment

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

Is this the new format? If so, can you issue a separate PR to improve this in the other Dockerfiles? Thanks! :)

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, MAINTAINER is listed as deprecated in the Dockerfile docs:

https://docs.docker.com/engine/reference/builder/#maintainer-deprecated

Will file another PR, thanks.

@wohali
Copy link
Member

wohali commented Jan 18, 2018

Couple of points:

  • I do know some people use the existing dev image as a self-contained 3-node cluster where setting up kube is prohibitive (i.e., inside of a Travis CI run). I worry about changing out the meaning of dev from underneath those people via a rename, though I agree with you that your proposal is more semantically meaningful. I don't know how we can get stats on how many people use the existing dev image, though.
  • I haven't had time to do a full diff of your proposed branch vs. the existing 2.1.1 version yet, to see any non-dev-specific changes you've made. If any improvements are there, I'd like to see those in a parallel PR against the non-dev assets as well. Keep in mind that those changes will ripple up into the Docker official couchdb image, and will undergo scrutiny of people who know more about this than you and I :) (reference: Update couchdb images, maintainer and source repo docker-library/official-images#3474).

@kocolosk
Copy link
Member Author

Hah, yeah, that was an impressive code review! I will be sure to double-check if there are additional PRs to file against the 2.1.1 image.

@wohali
Copy link
Member

wohali commented Jan 31, 2018

@daleharvey Are you still the right person to ping on this for PouchDB? Are you currently using the couchdb dev Docker image? If so, will @kocolosk 's changes above cause you any heartburn?

@wohali
Copy link
Member

wohali commented Apr 9, 2018

After much thought, I've decided that changing what dev means from a 3-node image to a single-node image is fine;, since we're adding a dev-cluster image.

Since I know you get busy @kocolosk I can finish the PR if you like, would like to get this merged for 2.2.0.

kocolosk added 3 commits April 9, 2018 11:40
This paves the way for a simpler dev image Dockerfile.
This dev image configuration is modeled after the 2.1.1 Dockerfile with
a few modifications useful for day-to-day development:

* The Dockerfile builds from git rather than the official source
  releases. The build is configurable using the following build_args:

  clone_url (default: https://gitbox.apache.org/repos/asf/couchdb.git)
  checkout_branch (default: master)
  configure_options (default: <blank>)

  The configure_options are passed directly to ./configure and can be
  used to e.g. --disable-docs or --disable-fauxton:

  docker build --build-arg checkout_branch=my-cool-feature dev/

* We take advantage of multi-stage builds [1] to create a series of
  layers that optimize build time without inflating the final image
  size. In normal development the layers that install runtime and
  build dependencies will be cached, and the build will start by
  updating and configuring the existing git clone.

This work includes the changes proposed in #50 and #57.
@wohali wohali force-pushed the better-faster-dev-builds branch 2 times, most recently from 5b2cea9 to 2ecab90 Compare April 9, 2018 17:00
@wohali wohali force-pushed the better-faster-dev-builds branch from 2ecab90 to 4ae5ad7 Compare April 10, 2018 16:00
@wohali
Copy link
Member

wohali commented Apr 11, 2018

I have taken the liberty of fixing the dev and dev-cluster targets. I have also updated to stretch and provided a candidate fix for #73.

I'll bake these changes here for a bit, and if they go well, use them to build the 2.2 images once CouchDB releases soon.

@wohali wohali merged commit 45b9dd1 into master Apr 11, 2018
@wohali wohali deleted the better-faster-dev-builds branch April 11, 2018 17:36
@kocolosk
Copy link
Member Author

Thanks @wohali this all looks great!

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

Successfully merging this pull request may close these issues.

3 participants