diff --git a/Dockerfiles/calicoctl-utility/Dockerfile.alpine b/Dockerfiles/calicoctl-utility/Dockerfile.alpine new file mode 100644 index 00000000..286a31b5 --- /dev/null +++ b/Dockerfiles/calicoctl-utility/Dockerfile.alpine @@ -0,0 +1,36 @@ +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/Makefile b/Dockerfiles/calicoctl-utility/Makefile new file mode 100644 index 00000000..9584e014 --- /dev/null +++ b/Dockerfiles/calicoctl-utility/Makefile @@ -0,0 +1,70 @@ +# Copyright 2019 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. + +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 + +IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} + +# Build calico-utility Docker image for this project +.PHONY: images +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) . +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) +endif diff --git a/Dockerfiles/calicoctl-utility/README b/Dockerfiles/calicoctl-utility/README new file mode 100644 index 00000000..1684d486 --- /dev/null +++ b/Dockerfiles/calicoctl-utility/README @@ -0,0 +1,15 @@ +Generic Docker Makefile +----------------------- + +This is a generic make and dockerfile for calicoctl utility container, which +can be used to create docker images using different calico releases. + +Usage: + +make IMAGE_TAG= + +eg: + +1. Create docker image for calicoctl release v3.4.0 + + make IMAGE_TAG=v3.4.0