Update Spyglass make images command

Bring files used in make images in line with other airship projects

Change-Id: Idb1858e3bc8fa64cfbeb768d999066cbd832e698
This commit is contained in:
Alexander Hughes 2019-04-24 09:41:05 -05:00
parent 7da3e51798
commit 56e37ed5c9
4 changed files with 35 additions and 11 deletions

View File

@ -21,7 +21,9 @@ PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false USE_PROXY ?= false
PUSH_IMAGE ?= false PUSH_IMAGE ?= false
LABEL ?= commit-id # use this variable for image labels added in internal build process
LABEL ?= org.airshipit.build=community
COMMIT ?= $(shell git rev-parse HEAD)
IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG) IMAGE ?= $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG)
PYTHON_BASE_IMAGE ?= python:3.6 PYTHON_BASE_IMAGE ?= python:3.6
export export
@ -34,13 +36,16 @@ images: build_spyglass
.PHONY: run_images .PHONY: run_images
run_images: run_spyglass run_images: run_spyglass
# Run the Spyglass container and exercise simple tests
.PHONY: run_spyglass .PHONY: run_spyglass
run_spyglass: build_spyglass run_spyglass: build_spyglass
tools/spyglass.sh --help tools/spyglass.sh --help
.PHONY: security .PHONY: security
security: security:
tox -c tox.ini -e bandit tox -e bandit
# TODO (alexanderhughes) add tox -e py36 tests once implemented in Spyglass
# Perform Linting # Perform Linting
.PHONY: lint .PHONY: lint
@ -53,7 +58,11 @@ format: py_format
.PHONY: build_spyglass .PHONY: build_spyglass
build_spyglass: build_spyglass:
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
docker build -t $(IMAGE) --network=host --label $(LABEL) -f images/spyglass/Dockerfile \ docker build -t $(IMAGE) --network=host --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)" \
-f images/spyglass/Dockerfile \
--build-arg FROM=$(PYTHON_BASE_IMAGE) \ --build-arg FROM=$(PYTHON_BASE_IMAGE) \
--build-arg http_proxy=$(PROXY) \ --build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \ --build-arg https_proxy=$(PROXY) \
@ -63,7 +72,11 @@ ifeq ($(USE_PROXY), true)
--build-arg NO_PROXY=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) \
--build-arg ctx_base=$(SPYGLASS_BUILD_CTX) . --build-arg ctx_base=$(SPYGLASS_BUILD_CTX) .
else else
docker build -t $(IMAGE) --network=host --label $(LABEL) -f images/spyglass/Dockerfile \ docker build -t $(IMAGE) --network=host --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)" \
-f images/spyglass/Dockerfile \
--build-arg FROM=$(PYTHON_BASE_IMAGE) \ --build-arg FROM=$(PYTHON_BASE_IMAGE) \
--build-arg ctx_base=$(SPYGLASS_BUILD_CTX) . --build-arg ctx_base=$(SPYGLASS_BUILD_CTX) .
endif endif
@ -71,6 +84,10 @@ ifeq ($(PUSH_IMAGE), true)
docker push $(IMAGE) docker push $(IMAGE)
endif endif
.PHONY: docs
docs: clean
tox -e docs
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf build rm -rf build

View File

@ -1,13 +1,19 @@
ARG FROM=python:3.6 ARG FROM=python:3.6
FROM ${FROM} FROM ${FROM}
LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
LABEL org.opencontainers.image.url='https://airshipit.org'
LABEL org.opencontainers.image.documentation='https://airship-spyglass.readthedocs.org'
LABEL org.opencontainers.image.source='https://opendev.org/airship/spyglass'
LABEL org.opencontainers.image.vendor='The Airship Authors'
LABEL org.opencontainers.image.licenses='Apache-2.0'
VOLUME /var/spyglass VOLUME /var/spyglass
WORKDIR /var/spyglass WORKDIR /var/spyglass
ARG ctx_base=./
COPY ${ctx_base}/requirements.txt /opt/spyglass/requirements.txt COPY requirements.txt /opt/spyglass/requirements.txt
RUN pip3 install --no-cache-dir -r /opt/spyglass/requirements.txt RUN pip3 install --no-cache-dir -r /opt/spyglass/requirements.txt
COPY ${ctx_base} /opt/spyglass COPY . /opt/spyglass
RUN pip3 install -e /opt/spyglass RUN pip3 install -e /opt/spyglass

View File

@ -5,6 +5,8 @@ set -e
: ${WORKSPACE:=$(pwd)} : ${WORKSPACE:=$(pwd)}
: ${IMAGE:=quay.io/airshipit/spyglass:latest} : ${IMAGE:=quay.io/airshipit/spyglass:latest}
: ${TERM_OPTS:=-t}
echo echo
echo "== NOTE: Workspace $WORKSPACE is the execution directory in the container ==" echo "== NOTE: Workspace $WORKSPACE is the execution directory in the container =="
echo echo
@ -13,8 +15,8 @@ echo
# host OS # host OS
container_workspace_path='/var/spyglass' container_workspace_path='/var/spyglass'
docker run --rm -t \ docker run --rm $TERM_OPTS \
--net=none \ --net=host \
--workdir="$container_workspace_path" \ --workdir="$container_workspace_path" \
-v "${WORKSPACE}:$container_workspace_path" \ -v "${WORKSPACE}:$container_workspace_path" \
"${IMAGE}" \ "${IMAGE}" \

View File

@ -17,14 +17,13 @@ whitelist_externals =
find find
commands = commands =
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete
{toxinidir}/tools/gate/run-unit-tests.sh '{posargs}'
[testenv:fmt] [testenv:fmt]
basepython = python3 basepython = python3
deps = deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
yapf -ir {toxinidir}/spyglass {toxinidir}/tests yapf -ir {toxinidir}/spyglass
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3