Skip to content

Commit 7489d19

Browse files
authored
Merge pull request Slicer#96 from Slicer/simplify-docker-image-management
docker: Remove build and run script, and use Makefile instead
2 parents df8d5f2 + cea9bca commit 7489d19

File tree

8 files changed

+61
-71
lines changed

8 files changed

+61
-71
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ head of the branch. If you add new commits onto the branch, those will also auto
5757
be run through the CI process. The status of the CI process (passing, failing, or in progress) will
5858
be displayed directly in the PR page in GitHub.
5959

60-
The CircleCI build will run according to the [circle.yml file](circle.yml),
60+
The CircleCI build will run according to the [.circleci/config.yml](.circleci/config.yml) file,
6161
which is useful as an example for how to set up your own environment for testing.
6262

6363
Your test results will be posted on [SlicerExecutionModel's dashboard](http://slicer.cdash.org/index.php?project=SlicerExecutionModel).
@@ -71,7 +71,7 @@ With each PR, SlicerExecutionModel is built and tested against multiple version
7171
environment is made available in docker images:
7272

7373
* Each environment is described in a ``Dockerfile`` found in a ``Docker-ITK-vX.Y.Z`` subdirectory of [test](./test).
74-
* Testing using a given environment is enabled updating the [circle.yml](circle.yml) file.
74+
* Testing using a given environment is enabled updating the [.circleci/config.yml](.circleci/config.yml) file.
7575
* Before enabling an environment, associated docker image has to be (1) built locally running the `build.sh` script
7676
and (2) manually pushed to [dockerhub](https://hub.docker.com/r/slicer/slicerexecutionmodel/tags/).
7777

test/Docker-ITK-v4.10.1_USE_SYSTEM_LIBRARIES-OFF/build.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/Docker-ITK-v4.10.1_USE_SYSTEM_LIBRARIES-OFF/run.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/Docker-ITK-v4.8.0_USE_SYSTEM_LIBRARIES-OFF/build.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/Docker-ITK-v4.8.0_USE_SYSTEM_LIBRARIES-OFF/run.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/Docker/Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# Parameters
3+
#
4+
5+
# Name of the docker executable
6+
DOCKER = docker
7+
8+
# DockerHub organization and repository to pull the images from
9+
ORG = slicer
10+
REPO = slicerexecutionmodel
11+
12+
DIRECTORIES = Docker-ITK-v4.10.1_USE_SYSTEM_LIBRARIES-OFF Docker-ITK-v4.8.0_USE_SYSTEM_LIBRARIES-OFF
13+
14+
# On CircleCI, do not attempt to delete container
15+
# See https://circleci.com/docs/docker-btrfs-error/
16+
RM = --rm
17+
ifeq ("$(CIRCLECI)", "true")
18+
RM =
19+
endif
20+
21+
#
22+
# images: This target builds all IMAGES (because it is the first one, it is built by default)
23+
#
24+
images: $(DIRECTORIES)
25+
26+
#
27+
# display
28+
#
29+
display_images:
30+
for directory in $(DIRECTORIES); do echo $$directory | rev | cut -d'/' -f 1 | rev | cut -d'-' -f 2- | tr '[:upper:]' '[:lower:]'; done
31+
32+
$(VERBOSE).SILENT: display_images
33+
34+
#
35+
# build implicit rule
36+
#
37+
$(DIRECTORIES): %: ../%/Dockerfile
38+
$(eval DIR := $(basename $@))
39+
$(eval TAG := $(shell echo $(DIR) | rev | cut -d'/' -f 1 | rev | cut -d'-' -f 2- | tr '[:upper:]' '[:lower:]'))
40+
$(eval IMAGEID := $(shell $(DOCKER) images -q $(ORG)/$(REPO):$(TAG)))
41+
$(DOCKER) build -t $(ORG)/$(REPO):$(TAG) \
42+
--build-arg IMAGE=$(ORG)/$(REPO):$(TAG) \
43+
--build-arg VCS_REF=`git rev-parse --short HEAD` \
44+
--build-arg VCS_URL=`git config --get remote.origin.url` \
45+
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
46+
../$@
47+
if [ -n "$(IMAGEID)" ]; then $(DOCKER) rmi "$(IMAGEID)"; fi
48+
49+
#
50+
# run implicit rule
51+
#
52+
.SECONDEXPANSION:
53+
$(addsuffix .run,$(DIRECTORIES)):
54+
$(eval DIR := $(basename $@))
55+
$(eval TAG := $(shell echo $(DIR) | rev | cut -d'/' -f 1 | rev | cut -d'-' -f 2- | tr '[:upper:]' '[:lower:]'))
56+
$(DOCKER) run -v $$(pwd)/../..:/usr/src/SlicerExecutionModel -ti $(RM) $(ORG)/$(REPO):$(TAG) bash
57+
58+
59+
.PHONY: images display_images $(DIRECTORIES) $(addsuffix .run,$(DIRECTORIES))

test/Docker/build.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/Docker/run.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)