Skip to content

Commit

Permalink
Speed up server testing by keeping the containers around
Browse files Browse the repository at this point in the history
This allows re-using containers, saving a tremendous amount of time.

The drawback here is that any environment change (on the docker /
podman containers side) is not detected. The way to deal with this
will be to create a process around major releases where I delete all
the containers and re-test from scratch.

Relates to: vedang#130
  • Loading branch information
vedang committed Oct 6, 2022
1 parent a4905d8 commit e6d1df4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
27 changes: 18 additions & 9 deletions server/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ DOCKER_OS = $(patsubst %.Dockerfile.in, %, \
$(notdir $(wildcard docker/templates/*.Dockerfile.in)))

# Arguments to pass to docker build .
DOCKER_BUILD_ARGS = -q
DOCKER_BUILD_ARGS = -q -t

# Advice make not to delete these "intermediate" files.
.PRECIOUS: docker/%.Dockerfile docker/.%.build
.PRECIOUS: docker/%.Dockerfile docker/.%.build docker/.%.container

.PHONY: all test check docker/build
# Avoid conflicts with real files
SUBDIRS = docker
.PHONY: subdirs $(SUBDIRS)

all: docker/test
test: docker/test
Expand All @@ -24,16 +26,22 @@ docker/%.Dockerfile: docker/templates/%.Dockerfile.in \
@echo Creating Dockerfile for target $*
cat $^ > $@

# Build the Dockerfile
# Build the Docker Image
docker/.%.build: docker/%.Dockerfile ../autobuild docker/lib
@echo Building target $*
podman image build $(DOCKER_BUILD_ARGS) -t epdfinfo/$* -f $< ../ || exit 0
@echo Building target image $*
podman image build $(DOCKER_BUILD_ARGS) epdfinfo/$* -f $< ../
touch $@

# Run the Dockerfile
docker/%: docker/.%.build
# Build the Docker Container
docker/.%.container: docker/.%.build
@echo Building target container $*
podman container create $(DOCKER_BUILD_ARGS) --name epdfinfo-$* epdfinfo/$*
touch $@

# Run the Containers generated by the dockerfile
docker/%: docker/.%.container
@echo Running tests on target $*
podman container run --rm --name epdfinfo-$* epdfinfo/$*
podman container start -a epdfinfo-$*

# Run all Dockerfiles
docker/test: docker/build $(patsubst %, docker/%, $(DOCKER_OS))
Expand All @@ -49,6 +57,7 @@ docker/clean: $(patsubst %, docker/.%.clean, $(DOCKER_OS))

clean: docker/clean
rm -f -- docker/.[^.]*.build
rm -f -- docker/.[^.]*.container
rm -f -- docker/*.Dockerfile

print:
Expand Down
1 change: 1 addition & 0 deletions server/test/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.Dockerfile
*.build
*.container

0 comments on commit e6d1df4

Please sign in to comment.