Skip to content
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

Globally prefer podman and better cross platform support #627

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ BUNDLE_FILENAME ?= data.json
PWD := $(shell pwd)
GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_COMMIT_TIMESTAMP := $(shell git log -1 --format=%ct $(GIT_COMMIT))
UNAME ?= $(shell uname -s || echo Unknown)
ifeq ($(UNAME), Linux)
SELINUX_MOUNT_CHAR = :z
else
SELINUX_MOUNT_CHAR =
endif

ifneq (,$(wildcard $(CURDIR)/.docker))
DOCKER_CONF := $(CURDIR)/.docker
Expand All @@ -25,33 +31,33 @@ help: ## Prints help for targets with comments
@grep -E '^[a-zA-Z0-9.\ _-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build:
@docker build -t $(IMAGE_NAME):latest -f Dockerfile .
@docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)
@$(CONTAINER_ENGINE) build -t $(IMAGE_NAME):latest -f Dockerfile .
@$(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)

bundle: ## Use qontract-validator image to bundle schemas into $BUNDLE_FILENAME NOTE
mkdir -p $(OUTPUT_DIR) fake_data fake_resources
@$(CONTAINER_ENGINE) run --rm \
-v $(PWD)/schemas:/schemas:z \
-v $(PWD)/graphql-schemas:/graphql:z \
-v $(PWD)/fake_data:/data:z \
-v $(PWD)/fake_resources:/resources:z \
-v $(PWD)/schemas:/schemas$(SELINUX_MOUNT_CHAR) \
-v $(PWD)/graphql-schemas:/graphql$(SELINUX_MOUNT_CHAR) \
-v $(PWD)/fake_data:/data$(SELINUX_MOUNT_CHAR) \
-v $(PWD)/fake_resources:/resources$(SELINUX_MOUNT_CHAR) \
Comment on lines +44 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:z means to share with multiple containers, I don't see where are we using that feature, all volume binds in this file are just read only mount, a simple :ro should be good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hemslo With regard to :z, while you are correct, the container engine facilitates the sharing through SELinux labels, which aren't available outside a SELinux-enabled environment (such as MacOS).

If we want to change the flag to :ro later, we can do that at a later date. I want this change to be minimal in scope without potentially breaking changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then can we only keep @$(CONTAINER_ENGINE) changes in this pr, or just remove :z in both cases? :ro is a good to have suffix to indicate readonly, then that system check is also not needed anymore, seems small enough to be included all in one change.

$(VALIDATOR_IMAGE):$(VALIDATOR_IMAGE_TAG) \
qontract-bundler /schemas /graphql/schema.yml /data /resources $(GIT_COMMIT) $(GIT_COMMIT_TIMESTAMP) > $(OUTPUT_DIR)/$(BUNDLE_FILENAME)
rm -rf fake_data fake_resources

validate: ## Use qcontract-validator image to show any validation errors of schemas in $BUNDLE_FILENAME
@$(CONTAINER_ENGINE) run --rm \
-v $(OUTPUT_DIR):/bundle:z \
-v $(OUTPUT_DIR):/bundle$(SELINUX_MOUNT_CHAR) \
$(VALIDATOR_IMAGE):$(VALIDATOR_IMAGE_TAG) \
qontract-validator --only-errors /bundle/$(BUNDLE_FILENAME)

gql_validate: ## Run qontract-server with the schema bundle and no data to reveal any GQL schema issues
@$(CONTAINER_ENGINE) run --rm \
-v $(OUTPUT_DIR):/bundle:z \
-v $(OUTPUT_DIR):/bundle$(SELINUX_MOUNT_CHAR) \
-p 4000:4000 \
-e LOAD_METHOD=fs \
-e DATAFILES_FILE=/bundle/$(BUNDLE_FILENAME) \
Expand All @@ -61,10 +67,10 @@ gql_validate: ## Run qontract-server with the schema bundle and no data to revea


build-test: clean
@docker build -t $(IMAGE_TEST) -f dockerfiles/Dockerfile.test .
@$(CONTAINER_ENGINE) build -t $(IMAGE_TEST) -f dockerfiles/Dockerfile.test .

test: build-test
@docker run --rm $(IMAGE_TEST)
@$(CONTAINER_ENGINE) run --rm $(IMAGE_TEST)

clean:
@rm -rf .tox .eggs *.egg-info buid .pytest_cache
Expand Down