Skip to content

Commit

Permalink
Add CONTAINER_ENGINE variable (#124)
Browse files Browse the repository at this point in the history
Add CONTAINER_ENGINE variable, with docker as default
to not break existing usages
  • Loading branch information
janboll authored Jan 17, 2022
1 parent a6ad25b commit 8efd831
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
IMAGE_NAME := quay.io/app-sre/qontract-server
IMAGE_TAG := $(shell git rev-parse --short=7 HEAD)
APP_INTERFACE_PATH ?= $(shell pwd)/../../service/app-interface
CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker)
SCHEMAS_PATH ?= $(shell pwd)/../qontract-schemas
SCHEMAS_DIR := $(SCHEMAS_PATH)/schemas
GRAPHQL_SCHEMA_DIR := $(SCHEMAS_PATH)/graphql-schemas
Expand All @@ -24,16 +25,16 @@ endif
dev: docker-run-clean bundle docker-run

bundle:
@docker pull $(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG)
@$(CONTAINER_ENGINE) pull $(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG)
mkdir -p $(BUNDLE_DIR)
@docker run --rm \
@$(CONTAINER_ENGINE) run --rm \
-v $(SCHEMAS_DIR):/schemas:z \
-v $(GRAPHQL_SCHEMA_DIR):/graphql:z \
-v $(DATA_DIR):/data:z \
-v $(RESOURCES_DIR):/resources:z \
$(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG) \
qontract-bundler /schemas /graphql/schema.yml /data /resources $(GIT_COMMIT) $(GIT_COMMIT_TIMESTAMP) > $(BUNDLE_DIR)/$(BUNDLE_FILENAME)
@docker run --rm \
@$(CONTAINER_ENGINE) run --rm \
-v $(BUNDLE_DIR):/bundle:z \
$(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG) \
qontract-validator --only-errors /bundle/$(BUNDLE_FILENAME)
Expand All @@ -42,20 +43,20 @@ run:
LOAD_METHOD=fs DATAFILES_FILE=$(BUNDLE_DIR)/$(BUNDLE_FILENAME) yarn run server

docker-run:
@docker run -it --rm \
@$(CONTAINER_ENGINE) run -it --rm \
-v $(BUNDLE_DIR):/bundle:z \
-p 4000:4000 \
-e LOAD_METHOD=fs \
-e DATAFILES_FILE=/bundle/$(BUNDLE_FILENAME) \
$(IMAGE_NAME):$(IMAGE_TAG)

docker-run-clean:
@docker ps -aq | xargs docker rm -f || true
@$(CONTAINER_ENGINE) ps -aq | xargs $(CONTAINER_ENGINE) rm -f || true

build:
@docker build --pull -t $(IMAGE_NAME):latest .
@docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)
@$(CONTAINER_ENGINE) build --pull -t $(IMAGE_NAME):latest .
@$(CONTAINER_ENGINE) tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)

push:
@docker --config=$(DOCKER_CONF) push $(IMAGE_NAME):latest
@docker --config=$(DOCKER_CONF) push $(IMAGE_NAME):$(IMAGE_TAG)
@$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(IMAGE_NAME):latest
@$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(IMAGE_NAME):$(IMAGE_TAG)

0 comments on commit 8efd831

Please sign in to comment.