-
Notifications
You must be signed in to change notification settings - Fork 29
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
Refactor Dockerfiles to use common base layer #92
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Note: FROM command is inserted by Makefile | ||
# TODO: As of Docker-CE 17.05, we could use this better approach instead: | ||
#ARG base_layer | ||
#FROM $base_layer | ||
|
||
MAINTAINER Ben Barsdell <benbarsdell@gmail.com> | ||
|
||
ARG make_args | ||
|
||
# Build the library | ||
WORKDIR /bifrost | ||
COPY . . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should create a .dockerignore file with at least There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it can be useful to have the git history inside the container, but perhaps I should be doing that with your approach of using the base container and mapping the source directory instead. In that case, this sounds like a good idea. |
||
RUN make clean && \ | ||
make -j16 $make_args && \ | ||
make doc && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve heard the best docker practice is to make containers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the make doc sounds like the right idea. Indeed the make clean is important to avoid strange errors when the user already built the library outside. I'll look into what's going on with version.py. We could probably also do make clean again after make install. |
||
make install | ||
|
||
WORKDIR /workspace | ||
RUN ["/bin/bash"] |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,23 +47,34 @@ python: libbifrost | |
.PHONY: python | ||
|
||
#GPU Docker build | ||
IMAGE_NAME ?= ledatelescope/bifrost | ||
docker: | ||
docker build --pull -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR) -f Dockerfile.gpu -t $(IMAGE_NAME) . | ||
docker-base: | ||
echo "FROM $(CUDA_IMAGE_NAME)" > _Dockerfile.tmp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These could all be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM |
||
cat Dockerfile.base >> _Dockerfile.tmp | ||
docker build --pull -t $(IMAGE_NAME):latest-base -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR)-base -f _Dockerfile.tmp . | ||
rm _Dockerfile.tmp | ||
.PHONY: docker-base | ||
|
||
docker: docker-base | ||
echo "FROM $(IMAGE_NAME):latest-base" > _Dockerfile.tmp | ||
cat Dockerfile >> _Dockerfile.tmp | ||
docker build --build-arg make_args="" -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR) -f _Dockerfile.tmp . | ||
rm _Dockerfile.tmp | ||
.PHONY: docker | ||
|
||
#GPU Docker prereq build | ||
# (To be used for testing new builds rapidly) | ||
IMAGE_NAME ?= ledatelescope/bifrost | ||
docker_prereq: | ||
docker build --pull -t $(IMAGE_NAME)_prereq:$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR) -f Dockerfile_prereq.gpu -t $(IMAGE_NAME)_prereq . | ||
.PHONY: docker_prereq | ||
|
||
#CPU-only Docker build | ||
IMAGE_NAME ?= ledatelescope/bifrost | ||
docker-cpu: | ||
docker build --pull -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR) -f Dockerfile.cpu -t $(IMAGE_NAME) . | ||
.PHONY: docker | ||
docker-base-cpu: | ||
echo "FROM $(CPU_IMAGE_NAME)" > _Dockerfile.tmp | ||
cat Dockerfile.base >> _Dockerfile.tmp | ||
docker build --pull -t $(IMAGE_NAME):latest-base-cpu -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR)-base-cpu -f _Dockerfile.tmp . | ||
rm _Dockerfile.tmp | ||
.PHONY: docker-base | ||
|
||
docker-cpu: docker-base-cpu | ||
echo "FROM $(IMAGE_NAME):latest-base-cpu" > _Dockerfile.tmp | ||
cat Dockerfile >> _Dockerfile.tmp | ||
docker build --build-arg make_args="NOCUDA=1" -t $(IMAGE_NAME):latest-cpu -t $(IMAGE_NAME):$(LIBBIFROST_MAJOR).$(LIBBIFROST_MINOR)-cpu -f _Dockerfile.tmp . | ||
rm _Dockerfile.tmp | ||
.PHONY: docker-cpu | ||
|
||
# TODO: Consider adding a mode 'develop=1' that makes symlinks instead of copying | ||
# the library and headers. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also build from streams (moby/moby#31236) which is nice, so we won't have to create a temporary file within the build context.