From 96fb4e1abaafa5b4d95a1cc0ec7bef92593f5dd8 Mon Sep 17 00:00:00 2001 From: Andrey Volkov Date: Wed, 24 Oct 2018 14:21:09 -0700 Subject: [PATCH] Add tests target --- Makefile | 63 +++++++++++++++++++++++++++++++++++++++ tools/install_packages.sh | 13 ++++++++ 2 files changed, 76 insertions(+) create mode 100755 tools/install_packages.sh diff --git a/Makefile b/Makefile index a93b581..82290f2 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,70 @@ # See the License for the specific language governing permissions and # limitations under the License. +IMAGE_PREFIX ?= airshipit +IMAGE_TAG ?= untagged +IMAGE_NAME := aptly +COMMIT ?= commit-id + +DOCKER_REGISTRY ?= quay.io +PUSH_IMAGE ?= false + +HELM := $(BUILD_DIR)/helm + +PROXY ?= http://proxy.foo.com:8000 +NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local +USE_PROXY ?= false + +UBUNTU_BASE_IMAGE ?= ubuntu:16.04 + +IMAGE:=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$(IMAGE_NAME):${IMAGE_TAG} + +.PHONY: validate +validate: lint tests + +.PHONY: tests +tests: clean build + docker run -d \ + --publish 8080:80 \ + --volume $(shell pwd)/assets/nginx:/opt/nginx \ + --name aptly \ + ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} + docker run --network host \ + --name target \ + --volume $(shell pwd)/tools:/opt \ + $(UBUNTU_BASE_IMAGE) /opt/install_packages.sh + +.PHONY: clean +clean: + docker rm -f aptly || true + docker rm -f target || true + .PHONY: lint lint: shellcheck assets/*.sh hadolint Dockerfile + +.PHONY: build +build: +ifeq ($(USE_PROXY), true) + docker build --network host -t $(IMAGE) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + -f Dockerfile \ + --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) . +else + docker build --network host -t $(IMAGE) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(IMAGE_NAME)" \ + -f Dockerfile . +endif +ifeq ($(PUSH_IMAGE), true) + docker push $(IMAGE) +endif diff --git a/tools/install_packages.sh b/tools/install_packages.sh new file mode 100755 index 0000000..502d672 --- /dev/null +++ b/tools/install_packages.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -o pipefail +set -o errexit +set -o xtrace + +apt update +apt install -y curl +curl -s localhost:8080/aptly_repo_signing.key | apt-key add - +echo 'deb http://localhost:8080 xenial main' > /etc/apt/sources.list +apt-get update +apt-cache policy accountsservice +apt-get install -y accountsservice