Merge "Add image build for kubernetes-entrypoint"

This commit is contained in:
Zuul 2018-04-27 21:44:27 +00:00 committed by Gerrit Code Review
commit 0d9fe59fb8
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# kubernetes-entrypoint git clone target
src

View File

@ -0,0 +1,10 @@
FROM docker.io/ubuntu:xenial
MAINTAINER sean.eagan@att.com
ARG BINARY_PATH
ARG BINARY_INSTALL_PATH=/usr/local/bin/kubernetes-entrypoint
ENV BINARY_INSTALL_PATH=${BINARY_INSTALL_PATH}
COPY ${BINARY_PATH} ${BINARY_INSTALL_PATH}
CMD ${BINARY_INSTALL_PATH}

View File

@ -0,0 +1,76 @@
# Copyright 2017 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.
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
# Git args
GIT_REPO ?= https://github.com/stackanetes/kubernetes-entrypoint.git
GIT_REF ?= master
GIT_CLONE_DIR = src
# Image args
IMAGE_REGISTRY ?= docker.io
IMAGE_NAME ?= kubernetes-entrypoint
IMAGE_PREFIX ?= openstackhelm
IMAGE_TAG ?= $(GIT_REF)
IMAGE_LABELS ?=
# Overrides above image args if specified.
IMAGE ?= ${IMAGE_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}$(if $(IMAGE_TAG),:$(IMAGE_TAG),)
# Build args
BINARY_INSTALL_PATH ?=
# Extra args to pass to Docker build
DOCKER_BUILD_OPTS ?=
.PHONY: all
all: clean checkout binary image push
# Remove source code
.PHONY: clean
clean:
rm -rf $(GIT_CLONE_DIR)
# Checkout source code
.PHONY: checkout
checkout:
git clone $(GIT_REPO) $(GIT_CLONE_DIR)
cd $(GIT_CLONE_DIR); git checkout $(GIT_REF) .
# Build binary
.PHONY: binary
binary:
cd $(GIT_CLONE_DIR); go build
# Internal variables
_BINARY_PATH := $(GIT_CLONE_DIR)/kubernetes-entrypoint
_BINARY_INSTALL_PATH_ARG := $(if $(BINARY_INSTALL_PATH),--build-arg BINARY_INSTALL_PATH="${BINARY_INSTALL_PATH}" ,)
_IMAGE_LABELS_ARG := $(if $(IMAGE_LABELS),--label="${IMAGE_LABELS}" ,)
# Build image
.PHONY: image
image:
docker build\
--build-arg BINARY_PATH=$(_BINARY_PATH)\
$(_BINARY_INSTALL_PATH_ARG)\
$(_IMAGE_LABELS_ARG)\
-t $(IMAGE)\
$(DOCKER_BUILD_OPTS)\
.
# Push image
.PHONY: push
push:
docker push $(IMAGE)

View File

@ -0,0 +1,25 @@
Kubernetes-Entrypoint Image Build
=================================
Builds an image with kubernetes-entrypoint for use with OpenStack-Helm.
Prerequisites
-------------
Must have golang 1.7.x installed in order to build the binary.
Instructions
------------
Build the Kubernetes-Entrypoint Image
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A known good image is published to docker hub on a fairly regular basis, but if
you wish to build your own image, from the directory containing this README run:
.. code:: bash
# Example configuration overrides, see Makefile for all available options:
# export IMAGE_REPO=quay.io
# export GIT_REPO=https://github.com/someuser/kubernetes-entrypoint.git
# export GIT_REF=someref
make