diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9dd3eb8c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.tox +.testrepository diff --git a/.zuul.yaml b/.zuul.yaml index d4ce9209..a5b9e4f3 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -7,11 +7,13 @@ - publish-tox-docs-infra check: jobs: + - elastic-recheck-container - elastic-recheck-tox-queries: voting: false - openstack-tox-linters gate: jobs: + - elastic-recheck-container - openstack-tox-linters - job: @@ -23,3 +25,14 @@ Uses tox with the ``queries`` environment. vars: tox_envlist: queries + +- job: + name: elastic-recheck-container + parent: opendev-build-docker-image + description: Build container images for elastic-recheck service + vars: + zuul_work_dir: src/opendev.org/opendev/elastic-recheck + docker_images: + - context: . + repository: opendevorg/elastic-recheck + target: elastic-recheck diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a790026a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:experimental +FROM opendevorg/python-builder:3.7 as elastic-recheck-builder + +COPY . /tmp/src +RUN assemble + +FROM opendevorg/python-base:3.7 as elastic-recheck + +COPY --from=elastic-recheck-builder /output/ /output +RUN /output/install-from-bindep && \ +rm -rf /output +COPY data/ /data/ +COPY queries/ /opt/elastic-recheck/queries + +# using root allows us to use same relative paths in configs for running outside +# containers, where ./data contains persistent configs and logs. +WORKDIR / +CMD /usr/local/bin/elastic-recheck -f data/elastic-recheck.conf ${ER_OPTS:-} diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b923a6ec --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +.EXPORT_ALL_VARIABLES: + +PYTHON ?= $(shell command -v python3 python|head -n1) +# Keep docker before podman due to: +# https://github.com/containers/podman/issues/7602 +ENGINE ?= $(shell command -v docker podman|head -n1) +# localhost/ prefix must be present in order to assure docker/podman compatibility: +# https://github.com/containers/buildah/issues/1034 +IMAGE_TAG=localhost/elastic-recheck +# Enable newer docker buildkit if available +DOCKER_BUILDKIT=1 + +.PHONY: default +default: help + +define PRINT_HELP_PYSCRIPT +import re, sys + +print("Usage: make \n") +cmds = {} +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + cmds.update({target: help}) +for cmd in sorted(cmds): + print(f" {cmd:12} {cmds[cmd]}") +endef +export PRINT_HELP_PYSCRIPT + +.PHONY: help +help: + @$(PYTHON) -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +.PHONY: build +build: ## Build image using docker + $(ENGINE) build -t $(IMAGE_TAG) . + @echo "Image size: $$(docker image inspect --format='scale=0; {{.Size}}/1024/1024' $(IMAGE_TAG) | bc)MB" + +.PHONY: into +into: ## Starts bash inside docker image + $(ENGINE) run -it $(IMAGE_TAG) /bin/bash + +.PHONY: dive +dive: ## Use `dive` tool to investigate container size + # https://github.com/wagoodman/dive + dive $(IMAGE_TAG) diff --git a/README.rst b/README.rst index 6f9ed356..a16427d6 100644 --- a/README.rst +++ b/README.rst @@ -237,6 +237,12 @@ Notes generated files you will need to host a Kibana3 with that dashboard. * View the OpenStack ElasticSearch `cluster health here`_. +Development +----------- + +In addition to using ``tox`` you can also run ``make`` in order +to list current container build and testing commands. + Future Work ----------- diff --git a/bindep.txt b/bindep.txt index d9216bc9..ea0450c9 100644 --- a/bindep.txt +++ b/bindep.txt @@ -1,15 +1,18 @@ # This is a cross-platform list tracking distribution packages needed by tests; # see http://docs.openstack.org/infra/bindep/ for additional information. -dbus-devel [platform:rpm] -dbus-glib-devel [platform:rpm] +dbus-devel [platform:rpm test compile] +dbus-glib-devel [platform:rpm test compile] +build-essential [test compile] +gcc [test compile] +g++ [test compile] language-pack-en [platform:ubuntu] -libffi-dev [platform:dpkg] -libffi-devel [platform:rpm] +libffi-dev [platform:dpkg test compile] +libffi-devel [platform:rpm test compile] # e-r->launchpadlib->keyring->secretstorage->cryptography->ssl -libssl-dev [platform:dpkg] -openssl-devel [platform:rpm !platform:suse] -libopenssl-devel [platform:suse !platform:rpm] +libssl-dev [platform:dpkg test compile] +openssl-devel [platform:rpm !platform:suse test compile] +libopenssl-devel [platform:suse !platform:rpm test compile] locales [platform:debian] -python3-dev [platform:dpkg] -python3-devel [platform:rpm] +python3-dev [platform:dpkg test compile] +python3-devel [platform:rpm test compile] diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 00000000..e69de29b