Merge "Containerize kubernetes-entrypoint image build"
This commit is contained in:
commit
ce49dbde8f
@ -1,5 +1,4 @@
|
||||
FROM docker.io/ubuntu:xenial
|
||||
MAINTAINER sean.eagan@att.com
|
||||
|
||||
ARG BINARY_PATH
|
||||
ARG BINARY_INSTALL_PATH=/usr/local/bin/kubernetes-entrypoint
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2017 The Openstack-Helm Authors.
|
||||
# Copyright 2018 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.
|
||||
@ -18,7 +18,8 @@ SHELL := /bin/bash
|
||||
# Git args
|
||||
GIT_REPO ?= https://github.com/stackanetes/kubernetes-entrypoint.git
|
||||
GIT_REF ?= master
|
||||
GIT_CLONE_DIR = src
|
||||
_GIT_CLONE_SUBDIR := src
|
||||
_GIT_CLONE_MOUNT_DIR := /go/src/github.com/stackanetes/kubernetes-entrypoint
|
||||
|
||||
# Image args
|
||||
IMAGE_REGISTRY ?= docker.io
|
||||
@ -28,46 +29,56 @@ IMAGE_TAG ?= $(GIT_REF)
|
||||
IMAGE_LABELS ?=
|
||||
# Overrides above image args if specified.
|
||||
IMAGE ?= ${IMAGE_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}$(if $(IMAGE_TAG),:$(IMAGE_TAG),)
|
||||
IMAGE_DOCKER_BUILD_OPTS ?=
|
||||
IMAGE_BINARY_INSTALL_PATH ?=
|
||||
|
||||
# Build args
|
||||
BINARY_INSTALL_PATH ?=
|
||||
# Go args
|
||||
GO_IMAGE ?= docker.io/golang:1.10
|
||||
GO_BUILD_OPTS ?=
|
||||
|
||||
# Extra args to pass to Docker build
|
||||
DOCKER_BUILD_OPTS ?=
|
||||
# Binary args
|
||||
_BINARY_SUBDIR := out
|
||||
_BINARY_PATH := $(_BINARY_SUBDIR)/kubernetes-entrypoint
|
||||
|
||||
.PHONY: all
|
||||
all: clean checkout binary image push
|
||||
|
||||
# Remove source code
|
||||
# Remove source code and binary
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(GIT_CLONE_DIR)
|
||||
rm -rf $(_GIT_CLONE_SUBDIR)
|
||||
|
||||
# Checkout source code
|
||||
.PHONY: checkout
|
||||
checkout:
|
||||
git clone $(GIT_REPO) $(GIT_CLONE_DIR)
|
||||
cd $(GIT_CLONE_DIR); git checkout $(GIT_REF) .
|
||||
git clone $(GIT_REPO) $(_GIT_CLONE_SUBDIR)
|
||||
cd $(_GIT_CLONE_SUBDIR); git checkout $(GIT_REF) .
|
||||
|
||||
# Build binary
|
||||
.PHONY: binary
|
||||
binary:
|
||||
cd $(GIT_CLONE_DIR); go build
|
||||
docker run\
|
||||
-v "$(shell pwd)/$(_GIT_CLONE_SUBDIR)":$(_GIT_CLONE_MOUNT_DIR)\
|
||||
`# Run as current user, not root, to avoid sudo usage in clean target`\
|
||||
-v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro\
|
||||
-u $(shell id -u ${USER}):$(shell id -g ${USER})\
|
||||
-w $(_GIT_CLONE_MOUNT_DIR)\
|
||||
$(GO_IMAGE)\
|
||||
go build -o "$(_BINARY_PATH)" $(GO_BUILD_OPTS)
|
||||
|
||||
# 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}" ,)
|
||||
_BINARY_INSTALL_PATH_ARG := $(if $(IMAGE_BINARY_INSTALL_PATH),--build-arg BINARY_INSTALL_PATH="${IMAGE_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)\
|
||||
--build-arg BINARY_PATH=/$(_GIT_CLONE_SUBDIR)/$(_BINARY_PATH)\
|
||||
$(_BINARY_INSTALL_PATH_ARG)\
|
||||
$(_IMAGE_LABELS_ARG)\
|
||||
-t $(IMAGE)\
|
||||
$(DOCKER_BUILD_OPTS)\
|
||||
$(IMAGE_DOCKER_BUILD_OPTS)\
|
||||
.
|
||||
|
||||
# Push image
|
||||
|
@ -6,7 +6,7 @@ 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.
|
||||
git, docker
|
||||
|
||||
Instructions
|
||||
------------
|
||||
@ -19,7 +19,7 @@ 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 IMAGE_REGISTRY=quay.io
|
||||
# export GIT_REPO=https://github.com/someuser/kubernetes-entrypoint.git
|
||||
# export GIT_REF=someref
|
||||
make
|
||||
|
Loading…
x
Reference in New Issue
Block a user