ba9579fafe
Lint gate (make lint) runs shellcheck on assets/* and hadolint Dockerfile. Check gate (make tests) builds and run container from image. Change-Id: I354cf96a4ddcd9f1f077a4a93869178ec6c366ab
89 lines
2.6 KiB
Makefile
89 lines
2.6 KiB
Makefile
# Copyright 2018 The Openstack-Helm Authors.
|
|
#
|
|
# 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.
|
|
|
|
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 test
|
|
|
|
.PHONY: test
|
|
test: test-containers
|
|
|
|
.PHONY: test-containers
|
|
test-containers: 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
|
|
docker run --rm -i hadolint/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
|
|
|
|
.PHONY: prepare
|
|
lint-install:
|
|
apt-get install -y shellcheck
|