From 0141d8b0b52b95b96dd6081ec66ae938f06acee3 Mon Sep 17 00:00:00 2001 From: Alexander Vlasov Date: Fri, 23 Aug 2019 11:30:02 -0500 Subject: [PATCH] Add calicoq utility to calicoctl-utility image Change-Id: I29b612dde82bda861a86c2c6a4ad9e05510f6e6a --- .../calicoctl-utility/Dockerfile.alpine | 36 ----------- .../Dockerfile_calicoctl_only.alpine | 36 +++++++++++ .../Dockerfile_calicoq_calicoctl.alpine | 49 +++++++++++++++ Dockerfiles/calicoctl-utility/Makefile | 61 ++++++------------- 4 files changed, 103 insertions(+), 79 deletions(-) delete mode 100644 Dockerfiles/calicoctl-utility/Dockerfile.alpine create mode 100644 Dockerfiles/calicoctl-utility/Dockerfile_calicoctl_only.alpine create mode 100644 Dockerfiles/calicoctl-utility/Dockerfile_calicoq_calicoctl.alpine diff --git a/Dockerfiles/calicoctl-utility/Dockerfile.alpine b/Dockerfiles/calicoctl-utility/Dockerfile.alpine deleted file mode 100644 index 286a31b5..00000000 --- a/Dockerfiles/calicoctl-utility/Dockerfile.alpine +++ /dev/null @@ -1,36 +0,0 @@ -ARG CALICOCTL_VERSION=v3.4.0 - -FROM quay.io/calico/ctl:${CALICOCTL_VERSION} -MAINTAINER Deepak Tiwari - -LABEL org.opencontainers.image.authors='att-comdev and Openstack-Helm Authors' -LABEL org.opencontainers.image.url='https://github.com/att-comdev/porthole' -LABEL org.opencontainers.image.documentation='https://github.com/att-comdev/porthole/blob/master/README' -LABEL org.opencontainers.image.source='https://github.com/att-comdev/porthole' -LABEL org.opencontainers.image.vendor='att-comdev and Openstack-Helm Authors' -LABEL org.opencontainers.image.licenses='BSD-3-Clause' - -RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d \ - && echo 'exit 101' >> /usr/sbin/policy-rc.d \ - && chmod +x /usr/sbin/policy-rc.d \ - && sed -i '/nobody/d' /etc/passwd \ - && echo "nobody:x:65534:65534:nobody:/nonexistent:/bin/bash" >> /etc/passwd \ - && apk add dpkg --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \ - && apk add --update dpkg \ - && touch /var/lib/dpkg/status \ - && apk update \ - && dpkg-divert --local --rename --add /sbin/initctl \ - && cp -a /usr/sbin/policy-rc.d /sbin/initctl \ - && sed -i 's/^exit.*/exit 0/' /sbin/initctl \ - && apk add --update \ - python python-dev py-pip build-base \ - sudo vim screen rsyslog \ - wget curl socat \ - && pip install oslo.rootwrap - -RUN mv /calicoctl /usr/local/bin/calicoctl \ - && chmod 0754 /usr/local/bin/calicoctl \ - && chmod 0754 /usr/bin/socat - -WORKDIR /tmp -ENTRYPOINT ["/bin/sh", "-c"] diff --git a/Dockerfiles/calicoctl-utility/Dockerfile_calicoctl_only.alpine b/Dockerfiles/calicoctl-utility/Dockerfile_calicoctl_only.alpine new file mode 100644 index 00000000..5ebd1917 --- /dev/null +++ b/Dockerfiles/calicoctl-utility/Dockerfile_calicoctl_only.alpine @@ -0,0 +1,36 @@ +ARG DOCKER_REGISTRY=quay.io +ARG CALICOCTL_IMAGE_PREFIX=calico/ctl +ARG CALICOCTL_VERSION=v3.4.4 + +ARG CALICOCTL_IMAGE="${DOCKER_REGISTRY}/${CALICOCTL_IMAGE_PREFIX}:${CALICOCTL_VERSION}" + +FROM ${CALICOCTL_IMAGE} + +ARG CALICOCTL_VERSION=v3.4.4 + +LABEL org.opencontainers.image.authors='Openstack-Helm Authors' \ + org.opencontainers.image.url='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility' \ + org.opencontainers.image.documentation='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility/README' \ + org.opencontainers.image.source='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility' \ + org.opencontainers.image.vendor='Openstack-Helm Authors' \ + org.opencontainers.image.licenses='BSD-3-Clause' \ + org.projectcalico.calicoctl.version="${CALICOCTL_VERSION}" + +RUN set -xe \ + && export DEBIAN_FRONTEND=noninteractive \ + && apk add dpkg --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \ + && apk add --update dpkg \ + && touch /var/lib/dpkg/status \ + && apk update \ + && apk add --update \ + python python-dev py-pip build-base \ + sudo vim screen rsyslog \ + wget curl socat \ + && pip install oslo.rootwrap + +RUN mv /calicoctl /usr/local/bin/calicoctl \ + && chmod 0754 /usr/local/bin/calicoctl \ + && chmod 0754 /usr/bin/socat + +WORKDIR /tmp +ENTRYPOINT ["/bin/sh", "-c"] diff --git a/Dockerfiles/calicoctl-utility/Dockerfile_calicoq_calicoctl.alpine b/Dockerfiles/calicoctl-utility/Dockerfile_calicoq_calicoctl.alpine new file mode 100644 index 00000000..d21cd588 --- /dev/null +++ b/Dockerfiles/calicoctl-utility/Dockerfile_calicoq_calicoctl.alpine @@ -0,0 +1,49 @@ +ARG DOCKER_REGISTRY=quay.io +ARG CALICOQ_IMAGE_PREFIX=tigera/calicoq +ARG CALICOQ_VERSION=v2.3.1 + +ARG CALICOQ_IMAGE="${DOCKER_REGISTRY}/${CALICOQ_IMAGE_PREFIX}:${CALICOQ_VERSION}" + +ARG CALICOCTL_IMAGE_PREFIX=tigera/calicoctl +ARG CALICOCTL_VERSION=v2.3.1 + +ARG CALICOCTL_IMAGE="${DOCKER_REGISTRY}/${CALICOCTL_IMAGE_PREFIX}:${CALICOCTL_VERSION}" + +FROM ${CALICOQ_IMAGE} AS stage_calicoq + +FROM ${CALICOCTL_IMAGE} + +ARG CALICOQ_VERSION=v2.3.1 +ARG CALICOCTL_VERSION=v2.3.1 + +LABEL org.opencontainers.image.authors='Openstack-Helm Authors' \ + org.opencontainers.image.url='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility' \ + org.opencontainers.image.documentation='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility/README' \ + org.opencontainers.image.source='https://opendev.org/airship/porthole/src/branch/master/Dockerfiles/calicoctl-utility' \ + org.opencontainers.image.vendor='Openstack-Helm Authors' \ + org.opencontainers.image.licenses='BSD-3-Clause' \ + io.tigera.calicoctl.version="${CALICOCTL_VERSION}" \ + io.tigera.calicoq.version="${CALICOQ_VERSION}" + +RUN set -xe \ + && export DEBIAN_FRONTEND=noninteractive \ + && apk add dpkg --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \ + && apk add --update dpkg \ + && touch /var/lib/dpkg/status \ + && apk update \ + && apk add --update \ + python python-dev py-pip build-base \ + sudo vim screen rsyslog \ + wget curl socat \ + && pip install oslo.rootwrap + +COPY --from=stage_calicoq /calicoq /usr/local/bin/calicoq + +RUN mv /calicoctl /usr/local/bin/calicoctl \ + && chmod 0754 /usr/local/bin/calicoctl \ + && chmod 0754 /usr/local/bin/calicoq \ + && chmod 0754 /usr/bin/socat + + +WORKDIR /tmp +ENTRYPOINT ["/bin/sh", "-c"] diff --git a/Dockerfiles/calicoctl-utility/Makefile b/Dockerfiles/calicoctl-utility/Makefile index 9584e014..5de287bf 100644 --- a/Dockerfiles/calicoctl-utility/Makefile +++ b/Dockerfiles/calicoctl-utility/Makefile @@ -14,22 +14,14 @@ SHELL := /bin/bash -DOCKER_REGISTRY ?= quay.io -IMAGE_NAME ?= calicoctl-utility -IMAGE_PREFIX ?= attcomdev -IMAGE_TAG ?= latest -PROXY ?= http://proxy.foo.com:8000 -NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local -USE_PROXY ?= false -PUSH_IMAGE ?= false -# use this variable for image labels added in internal build process -LABEL ?= org.attcomdev.build=community -COMMIT ?= $(shell git rev-parse HEAD) -CALICOCTL_BASE_IMAGE ?= ${DOCKER_REGISTRY}/calico/ctl:${CALICOCTL_VERSION} -CALICOCTL_BUILD_CTX ?= calicoctl-utility -export +DOCKER_REGISTRY ?= quay.io +IMAGE_NAME ?= calico-utility +IMAGE_PREFIX ?= airship/porthole +IMAGE_TAG ?= latest +BUILD_TYPE ?= community +OS_RELEASE ?= alpine -IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} +IMAGE := $(DOCKER_REGISTRY)/$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG) # Build calico-utility Docker image for this project .PHONY: images @@ -38,33 +30,16 @@ images: build_$(IMAGE_NAME) # Make targets intended for use by the primary targets above. .PHONY: build_$(IMAGE_NAME) build_$(IMAGE_NAME): -ifeq ($(USE_PROXY), true) - docker build -t $(IMAGE) --network=host -f Dockerfile.alpine \ - --label $(LABEL) \ - --label CALICOCTL_VERSION=$(IMAGE_TAG) \ - --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.alpine \ - --build-arg FROM=$(CALICOCTL_BASE_IMAGE) \ - --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 ctx_base=$(CALICOCTL_BUILD_CTX) . +ifeq ($(BUILD_TYPE), community) + docker build -f Dockerfile_calicoctl_only.$(OS_RELEASE) \ + --network host \ + $(EXTRA_BUILD_ARGS) \ + -t $(IMAGE) \ + . else - docker build -t $(IMAGE) --network=host -f Dockerfile.alpine \ - --label $(LABEL) \ - --label CALICOCTL_VERSION=$(IMAGE_TAG) \ - --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.alpine \ - --build-arg FROM=$(CALICOCTL_BASE_IMAGE) \ - --build-arg ctx_base=$(CALICOCTL_BUILD_CTX) . -endif -ifeq ($(PUSH_IMAGE), true) - docker push $(IMAGE) + docker build -f Dockerfile_calicoq_calicoctl.$(OS_RELEASE) \ + --network host \ + $(EXTRA_BUILD_ARGS) \ + -t $(IMAGE) \ + . endif