Skip to content

Commit

Permalink
Allow to disable pulling of base image
Browse files Browse the repository at this point in the history
if one wants to use their local base image.
  • Loading branch information
jpopelka committed May 9, 2022
1 parent 47de4ac commit ef2a002
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
BASE_IMAGE ?= quay.io/packit/base
PULL_BASE_IMAGE ? = true # true|false
SERVICE_IMAGE ?= quay.io/packit/packit-service:dev
WORKER_IMAGE ?= quay.io/packit/packit-worker:dev
TEST_IMAGE ?= quay.io/packit/packit-service-tests:stg
PULL_TEST_IMAGE ?= missing
PULL_TEST_IMAGE ?= missing # missing|always|never
TEST_TARGET ?= ./tests/unit ./tests/integration/
CONTAINER_ENGINE ?= $(shell command -v podman 2> /dev/null || echo docker)
ANSIBLE_PYTHON ?= $(shell command -v /usr/bin/python3 2> /dev/null || echo /usr/bin/python2)
Expand All @@ -16,21 +17,37 @@ COMPOSE ?= docker-compose
MY_ID ?= `id -u`

service: files/install-deps.yaml files/recipe.yaml
$(CONTAINER_ENGINE) pull $(BASE_IMAGE)
$(CONTAINER_ENGINE) build --rm -t $(SERVICE_IMAGE) -f files/docker/Dockerfile --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
--pull=$(PULL_BASE_IMAGE) \
-t $(SERVICE_IMAGE) \
-f files/docker/Dockerfile \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

worker: files/install-deps-worker.yaml files/recipe-worker.yaml
$(CONTAINER_ENGINE) pull $(BASE_IMAGE)
$(CONTAINER_ENGINE) build --rm -t $(WORKER_IMAGE) -f files/docker/Dockerfile.worker --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
--pull=$(PULL_BASE_IMAGE) \
-t $(WORKER_IMAGE) \
-f files/docker/Dockerfile.worker \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

check:
find . -name "*.pyc" -exec rm {} \;
PYTHONPATH=$(CURDIR) PYTHONDONTWRITEBYTECODE=1 python3 -m pytest --color=$(COLOR) --verbose --showlocals --cov=packit_service --cov-report=$(COV_REPORT) $(TEST_TARGET)

# In most cases you don't need to build your test-image, the one in registry should be all you need.
build-test-image: files/install-deps-worker.yaml files/install-deps.yaml files/recipe-tests.yaml
$(CONTAINER_ENGINE) build --rm -t $(TEST_IMAGE) -f files/docker/Dockerfile.tests --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
-t $(TEST_IMAGE) \
-f files/docker/Dockerfile.tests \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

# We use a test image pre-built (by Github action) from latest commit in main.
# The PULL_TEST_IMAGE specifies whether the image is downloaded before running tests in a container.
# Default is 'missing', which means that it's downloaded/updated ONLY if missing.
# Set PULL_TEST_IMAGE=always to pull/update the test image before running tests.
check-in-container:
@# don't use -ti here in CI, TTY is not allocated in zuul
echo $(SOURCE_BRANCH)
Expand Down

0 comments on commit ef2a002

Please sign in to comment.