From 0c3f0e848a70b6700570179eaaba9dd2cff7fab1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kalynovskyi Date: Wed, 24 Mar 2021 20:09:42 +0000 Subject: [PATCH] Update libvrit image and push it to quay. The commit adds standard Makefile that will allow to push the image to airshipit repositories. Also it sets libvirt daemon to run as root this is needed, because host os doesn't have libvirt user on it (libvirt) is installed in container. Change-Id: Ifbca013496636ed32a1145303136aa28d02c3d1a --- {vino-libvirt => libvirt}/Dockerfile | 0 libvirt/Makefile | 98 +++++++++++++++++++++++++ {vino-libvirt => libvirt}/libvirt.sh | 0 {vino-libvirt => libvirt}/libvirtd.conf | 0 {vino-libvirt => libvirt}/qemu.conf | 4 +- 5 files changed, 100 insertions(+), 2 deletions(-) rename {vino-libvirt => libvirt}/Dockerfile (100%) create mode 100644 libvirt/Makefile rename {vino-libvirt => libvirt}/libvirt.sh (100%) rename {vino-libvirt => libvirt}/libvirtd.conf (100%) rename {vino-libvirt => libvirt}/qemu.conf (57%) diff --git a/vino-libvirt/Dockerfile b/libvirt/Dockerfile similarity index 100% rename from vino-libvirt/Dockerfile rename to libvirt/Dockerfile diff --git a/libvirt/Makefile b/libvirt/Makefile new file mode 100644 index 0000000..77b32d5 --- /dev/null +++ b/libvirt/Makefile @@ -0,0 +1,98 @@ + +# Copyright 2021 AT&T Intellectual Property. All other rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +SHELL := /bin/bash +BUILD_DIR ?= build +PUSH_IMAGE ?= false +IMAGE_ID ?= none +COMMIT ?= $(shell git rev-parse HEAD) +LABEL ?= org.airshipit.build=community +IMAGE_NAME ?= libvirt +DOCKER_REGISTRY ?= quay.io +IMAGE_PREFIX ?= airshipit +IMAGE_TAG ?= latest +DISTRO ?= ubuntu_bionic +IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO} +SH_TO_CHECK := $(wildcard files/*.sh ) +PROXY ?= http://proxy.foo.com:8000 +NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local +USE_PROXY ?= false +all: lint images +check-docker: + @if [ -z $$(which docker) ]; then \ + echo "Missing \`docker\` client which is required for development"; \ + exit 2; \ + fi +images: check-docker build_libvirt +docs: clean build_docs +build_docs: + echo TODO +run_images: run_libvirt +run_libvirt: + echo TODO +build_libvirt: + mkdir -p $(BUILD_DIR) +ifeq ($(IMAGE_ID), none) +ifeq ($(USE_PROXY), true) + docker build . \ + --iidfile $(BUILD_DIR)/image_id \ + --tag $(IMAGE) \ + --label $(LABEL) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=\ + $(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + --build-arg http_proxy=$(PROXY) \ + --build-arg https_proxy=$(PROXY) \ + --build-arg HTTP_PROXY=$(PROXY) \ + --build-arg HTTPS_PROXY=$(PROXY) \ + --build-arg no_proxy=$(NO_PROXY) \ + --build-arg NO_PROXY=$(NO_PROXY) \ + --build-arg GIT_COMMIT=$(COMMIT) +else + docker build . \ + --iidfile $(BUILD_DIR)/image_id \ + --tag $(IMAGE) \ + --label $(LABEL) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=\ + $(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + --build-arg GIT_COMMIT=$(COMMIT) +endif +else + echo $(IMAGE_ID) > $(BUILD_DIR)/image_id +endif +ifeq ($(PUSH_IMAGE), true) + docker push $(IMAGE) +endif +clean: +ifeq ($(IMAGE_ID), none) + if [[ -s $(BUILD_DIR)/image_id ]]; \ + then \ + docker rmi $$(cat $(BUILD_DIR)/image_id); \ + fi +endif + rm -rf $(BUILD_DIR) +# style checks +lint: test-shellcheck +tests: lint unit_tests run_libvirt +test-shellcheck: $(SH_TO_CHECK) +unit_tests: + echo TODO +$(SH_TO_CHECK): + docker run --rm -v $(shell pwd):/mnt \ + nlknguyen/alpine-shellcheck -x /mnt/$(@) +.PHONY: test clean $(SH_TO_CHECK) test-shellcheck tests lint build_libvirt \ + run_libvirt run_images all build_docs docs check-docker images diff --git a/vino-libvirt/libvirt.sh b/libvirt/libvirt.sh similarity index 100% rename from vino-libvirt/libvirt.sh rename to libvirt/libvirt.sh diff --git a/vino-libvirt/libvirtd.conf b/libvirt/libvirtd.conf similarity index 100% rename from vino-libvirt/libvirtd.conf rename to libvirt/libvirtd.conf diff --git a/vino-libvirt/qemu.conf b/libvirt/qemu.conf similarity index 57% rename from vino-libvirt/qemu.conf rename to libvirt/qemu.conf index 6c5e418..94aeffb 100644 --- a/vino-libvirt/qemu.conf +++ b/libvirt/qemu.conf @@ -1,4 +1,4 @@ stdio_handler = "file" -user = "libvirt-qemu" -group = "kvm" +user = "root" +group = "root" security_driver = "none"