Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(push_script): refactor makefile and push scirpt #59

Merged
merged 3 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The images can be pushed to any docker/image registeries
# like docker hub, quay. The registries are specified in
# the `build/push` script.
#
# The images of a project or company can then be grouped
# or hosted under a unique organization key like `openebs`
#
# Each component (container) will be pushed to a unique
# repository under an organization.
# Putting all this together, an unique uri for a given
# image comprises of:
# <registry url>/<image org>/<image repo>:<image-tag>
#
# IMAGE_ORG can be used to customize the organization
# under which images should be pushed.
# By default the organization name is `openebs`.

ifeq (${IMAGE_ORG}, )
IMAGE_ORG="openebs"
export IMAGE_ORG
endif

# Specify the docker arg for repository url
ifeq (${DBUILD_REPO_URL}, )
DBUILD_REPO_URL="https://github.com/openebs/cstor-operators"
export DBUILD_REPO_URL
endif

# Specify the docker arg for website url
ifeq (${DBUILD_SITE_URL}, )
DBUILD_SITE_URL="https://openebs.io"
export DBUILD_SITE_URL
endif

# Specify the date of build
DBUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')

HUB_USER?=openebs

# Determine the arch/os
ifeq (${XC_OS}, )
Expand Down Expand Up @@ -42,6 +77,8 @@ else
export BASE_TAG
endif

export DBUILD_ARGS=--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REPO_URL=${DBUILD_REPO_URL} --build-arg DBUILD_SITE_URL=${DBUILD_SITE_URL} --build-arg ARCH=${ARCH}

# Specify the name of cstor-base image
CSTOR_BASE_IMAGE= openebs/cstor-base:${BASE_TAG}
export CSTOR_BASE_IMAGE
Expand Down Expand Up @@ -100,63 +137,63 @@ cvc-operator:
.PHONY: cvc-operator-image.amd64
cvc-operator-image.amd64:
@echo -n "--> cvc-operator image <--"
@echo "${HUB_USER}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${CVC_OPERATOR} CTLNAME=${CVC_OPERATOR} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${CVC_OPERATOR}/${CVC_OPERATOR} build/cvc-operator/
@cd build/${CVC_OPERATOR} && sudo docker build -t ${HUB_USER}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} .
@cd build/${CVC_OPERATOR} && sudo docker build -t ${IMAGE_ORG}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG} ${DBUILD_ARGS} .
@rm build/${CVC_OPERATOR}/${CVC_OPERATOR}

.PHONY: cvc-operator-image.arm64
cvc-operator-image.arm64:
@echo "----------------------------"
@echo -n "--> arm64 based cvc-operator image "
@echo "${HUB_USER}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${CVC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${CVC_OPERATOR} CTLNAME=${CVC_OPERATOR} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${CVC_OPERATOR}/${CVC_OPERATOR} build/cvc-operator/
@cd build/${CVC_OPERATOR} && sudo docker build -t ${HUB_USER}/${CVC_OPERATOR_ARM64}:${IMAGE_TAG} -f Dockerfile.arm64 --build-arg BUILD_DATE=${BUILD_DATE} .
@cd build/${CVC_OPERATOR} && sudo docker build -t ${IMAGE_ORG}/${CVC_OPERATOR_ARM64}:${IMAGE_TAG} -f Dockerfile.arm64 ${DBUILD_ARGS} .
@rm build/${CVC_OPERATOR}/${CVC_OPERATOR}

.PHONY: volume-manager-image.amd64
volume-manager-image.amd64:
@echo -n "--> volume manager image <--"
@echo "${HUB_USER}/${VOLUME_MANAGER_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${VOLUME_MANAGER_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${VOLUME_MANAGER} CTLNAME=${VOLUME_MANAGER} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${VOLUME_MANAGER}/${VOLUME_MANAGER} build/volume-manager/
@cd build/${VOLUME_MANAGER} && sudo docker build -t ${HUB_USER}/${VOLUME_MANAGER_REPO_NAME}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} .
@cd build/${VOLUME_MANAGER} && sudo docker build -t ${IMAGE_ORG}/${VOLUME_MANAGER_REPO_NAME}:${IMAGE_TAG} ${DBUILD_ARGS} .
@rm build/${VOLUME_MANAGER}/${VOLUME_MANAGER}

.PHONY: cspc-operator-image.amd64
cspc-operator-image.amd64:
@echo -n "--> cspc-operator image <--"
@echo "${HUB_USER}/${CSPC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${CSPC_OPERATOR_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${CSPC_OPERATOR} CTLNAME=${CSPC_OPERATOR} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${CSPC_OPERATOR}/${CSPC_OPERATOR} build/cspc-operator/
@cd build/${CSPC_OPERATOR} && sudo docker build -t ${HUB_USER}/${CSPC_OPERATOR_REPO_NAME}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} .
@cd build/${CSPC_OPERATOR} && sudo docker build -t ${IMAGE_ORG}/${CSPC_OPERATOR_REPO_NAME}:${IMAGE_TAG} ${DBUILD_ARGS} .
@rm build/${CSPC_OPERATOR}/${CSPC_OPERATOR}

.PHONY: pool-manager-image.amd64
pool-manager-image.amd64:
@echo -n "--> pool manager image <--"
@echo "${HUB_USER}/${POOL_MANAGER_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${POOL_MANAGER_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${POOL_MANAGER} CTLNAME=${POOL_MANAGER} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${POOL_MANAGER}/${POOL_MANAGER} build/pool-manager/
@cd build/${POOL_MANAGER} && sudo docker build -t ${HUB_USER}/${POOL_MANAGER_REPO_NAME}:${IMAGE_TAG} --build-arg BASE_IMAGE=${CSTOR_BASE_IMAGE} --build-arg BUILD_DATE=${BUILD_DATE} . --no-cache
@cd build/${POOL_MANAGER} && sudo docker build -t ${IMAGE_ORG}/${POOL_MANAGER_REPO_NAME}:${IMAGE_TAG} --build-arg BASE_IMAGE=${CSTOR_BASE_IMAGE} ${DBUILD_ARGS} . --no-cache
@rm build/${POOL_MANAGER}/${POOL_MANAGER}

.PHONY: cstor-webhook-image.amd64
cstor-webhook-image.amd64:
@echo "----------------------------"
@echo -n "--> cstor-webhook image "
@echo "${HUB_USER}/${CSTOR_WEBHOOK_REPO_NAME}:${IMAGE_TAG}"
@echo "${IMAGE_ORG}/${CSTOR_WEBHOOK_REPO_NAME}:${IMAGE_TAG}"
@echo "----------------------------"
@PNAME=${CSTOR_WEBHOOK} CTLNAME=${WEBHOOK_REPO} sh -c "'$(PWD)/build/build.sh'"
@cp bin/${CSTOR_WEBHOOK}/${WEBHOOK_REPO} build/cstor-webhook/
@cd build/${CSTOR_WEBHOOK} && sudo docker build -t ${HUB_USER}/${CSTOR_WEBHOOK_REPO_NAME}:${IMAGE_TAG} --build-arg BUILD_DATE=${BUILD_DATE} .
@cd build/${CSTOR_WEBHOOK} && sudo docker build -t ${IMAGE_ORG}/${CSTOR_WEBHOOK_REPO_NAME}:${IMAGE_TAG} ${DBUILD_ARGS} .
@rm build/${CSTOR_WEBHOOK}/${WEBHOOK_REPO}

.PHONY: all.amd64
Expand Down
9 changes: 7 additions & 2 deletions build/cspc-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ RUN apk add --no-cache \

COPY cspc-operator /usr/local/bin/cspc-operator

ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

ARG BUILD_DATE
LABEL org.label-schema.name="cspc-operator"
LABEL org.label-schema.description="CSPC Operator for OpenEBS cStor engine"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT ["/usr/local/bin/cspc-operator"]
13 changes: 10 additions & 3 deletions build/cstor-webhook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ RUN apt-get update && apt-get install -y \
ADD webhook /usr/local/bin/webhook


ARG BUILD_DATE

ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cstor-webhook"
LABEL org.label-schema.description="webhook admission server policy for CStor"
LABEL org.label-schema.description="Webhook admission server for cStor"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT ["/usr/local/bin/webhook"]

10 changes: 8 additions & 2 deletions build/cvc-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ RUN apk add --no-cache \

COPY cvc-operator /usr/local/bin/cvc-operator

ARG BUILD_DATE
ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cvc-operator"
LABEL org.label-schema.description="Operator for OpenEBS cStor csi volumes"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT ["/usr/local/bin/cvc-operator"]
10 changes: 8 additions & 2 deletions build/cvc-operator/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ RUN apk add --no-cache \

COPY cvc-operator /usr/local/bin/cvc-operator

ARG BUILD_DATE
ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cvc-operator"
LABEL org.label-schema.description="Operator for OpenEBS cStor csi volumes"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT ["/usr/local/bin/cvc-operator"]
12 changes: 9 additions & 3 deletions build/pool-manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ RUN chmod +x /usr/local/bin/execute.sh
RUN apt install netcat -y
RUN chmod +x /usr/local/bin/entrypoint.sh

ARG BUILD_DATE
ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cstor-pool-manager"
LABEL org.label-schema.description="OpenEBS"
LABEL org.label-schema.description="Pool manager for cStor pool"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT entrypoint.sh
EXPOSE 7676
12 changes: 10 additions & 2 deletions build/push
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ echo "Set the build/unique image tag as: ${BUILD_TAG}"

function TagAndPushImage() {
REPO="$1"
TAG="$2"
# Trim the `v` from the TAG if it exists
# Example: v1.10.0 maps to 1.10.0
# Example: 1.10.0 maps to 1.10.0
# Example: v1.10.0-custom maps to 1.10.0-custom
TAG="${2#v}"

# Add an option to specify a custom TAG_SUFFIX
# via environment variable. Default is no tag.
# Example suffix could be "-debug" of "-dev"
IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}";

IMAGE_URI="${REPO}:${TAG}";
sudo docker tag ${IMAGEID} ${IMAGE_URI};
echo " push ${IMAGE_URI}";
sudo docker push ${IMAGE_URI};
Expand Down
11 changes: 9 additions & 2 deletions build/volume-manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ COPY entrypoint.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/entrypoint.sh

ARG BUILD_DATE
ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cstor-volume-manager"
LABEL org.label-schema.description="OpenEBS"
LABEL org.label-schema.description="Volume manager for cStor volumes"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT entrypoint.sh
EXPOSE 7676 7777
12 changes: 9 additions & 3 deletions build/volume-manager/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ COPY entrypoint.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/entrypoint.sh

ARG BUILD_DATE
ARG ARCH
ARG DBUILD_DATE
ARG DBUILD_REPO_URL
ARG DBUILD_SITE_URL

LABEL org.label-schema.name="cstor-volume-mgmt"
LABEL org.label-schema.description="OpenEBS"
LABEL org.label-schema.description="Volume manager for cStor volumes"
LABEL org.label-schema.url="http://www.openebs.io/"
LABEL org.label-schema.vcs-url="https://github.com/openebs/cstor-operators"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.build-date=$DBUILD_DATE
LABEL org.label-schema.vcs-url=$DBUILD_REPO_URL
LABEL org.label-schema.url=$DBUILD_SITE_URL

ENTRYPOINT entrypoint.sh
EXPOSE 7676 7777