Created
June 24, 2014 13:17
-
-
Save bloodearnest/554fa5552a0dea8b5605 to your computer and use it in GitHub Desktop.
Building off a base image for dev/prod images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GOAL: Use docker to build some images: | |
- a base image | |
- a dev image, from base, with extra dev deps, and the source code mounted as a host volume | |
- a prod image, from base, with src explicitly ADDed into the image as a stand alone executable | |
SUBGOALS: | |
- make use of docker's cache for faster building | |
A base image: | |
$ cat base.docker | |
# A context-less dockerfile that builds a base image | |
FROM ubuntu:precise | |
RUN echo "deb http://archive.me.com/ubuntu/ precise main" > /etc/apt/sources.list.d/mine.list | |
RUN apt-get update | |
RUN apt-get install -y --no-install-recommends some stuff | |
RUN apt-get install -y --no-install-recommends more stuff | |
RUN mkdir -p /srv/app/{src,log,etc,scripts} | |
$ | |
$ docker build -t base - < base.docker | |
... | |
That works fine, no problems | |
For the dev image, it should install dev dependancies, which include python packages from a requirements.txt file in the src tree. But the source tree will be a volume at run time, so won't be available at build time. | |
So, AIUI I can do 3 things | |
1) Write a straight up Dockerfile (which can have context), which ADDs the requirements.txt into the image, and pip installed from that build. Problem: you can only have 1 Dockerfile (build context is only supported in that case), and I would want to use that for the prod image as well... | |
2) Script the changes to base image and commit the final image as the dev image. Problems: no nice docker caching of changes, full rebuild every time. | |
3) Rather than use requirements.txt, embed the actual dependancies in a context-less dockerfile. Problem: very different process for developers, prefer to stick with python standard of requirements.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment