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
USE_PROXY ?= 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)
PYTHON_BASE_IMAGE ?= python:3.6
export
@ -34,13 +36,16 @@ images: build_spyglass
.PHONY: run_images
run_images: run_spyglass
# Run the Spyglass container and exercise simple tests
.PHONY: run_spyglass
run_spyglass: build_spyglass
tools/spyglass.sh --help
.PHONY: security
security:
tox -c tox.ini -e bandit
tox -e bandit
# TODO (alexanderhughes) add tox -e py36 tests once implemented in Spyglass
# Perform Linting
.PHONY: lint
@ -53,7 +58,11 @@ format: py_format
.PHONY: build_spyglass
build_spyglass:
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 http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
@ -63,7 +72,11 @@ ifeq ($(USE_PROXY), true)
--build-arg NO_PROXY=$(NO_PROXY) \
--build-arg ctx_base=$(SPYGLASS_BUILD_CTX) .
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 ctx_base=$(SPYGLASS_BUILD_CTX) .
endif
@ -71,6 +84,10 @@ ifeq ($(PUSH_IMAGE), true)
docker push $(IMAGE)
endif
.PHONY: docs
docs: clean
tox -e docs
.PHONY: clean
clean:
rm -rf build

View File

@ -1,13 +1,19 @@
ARG FROM=python:3.6
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
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
COPY ${ctx_base} /opt/spyglass
COPY . /opt/spyglass
RUN pip3 install -e /opt/spyglass

View File

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

View File

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