Skip to content

Commit

Permalink
add DOCKER_REPO to specify full image repository (#2207) (#2216)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 17, 2020
1 parent aab079f commit dbd721a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Set DEBUGGER=1 to build debug symbols
LDFLAGS = $(if $(DEBUGGER),,-s -w) $(shell ./hack/version.sh)

# SET DOCKER_REGISTRY to change the docker registry
DOCKER_REGISTRY := $(if $(DOCKER_REGISTRY),$(DOCKER_REGISTRY),localhost:5000)

GOVER_MAJOR := $(shell go version | sed -E -e "s/.*go([0-9]+)[.]([0-9]+).*/\1/")
GOVER_MINOR := $(shell go version | sed -E -e "s/.*go([0-9]+)[.]([0-9]+).*/\2/")
GO113 := $(shell [ $(GOVER_MAJOR) -gt 1 ] || [ $(GOVER_MAJOR) -eq 1 ] && [ $(GOVER_MINOR) -ge 13 ]; echo $$?)
Expand All @@ -19,6 +16,8 @@ GOENV := GO15VENDOREXPERIMENT="1" CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GO_BUILD := $(GO) build -trimpath

DOCKER_REGISTRY ?= localhost:5000
DOCKER_REPO ?= ${DOCKER_REGISTRY}/pingcap
IMAGE_TAG ?= latest
PACKAGE_LIST := go list ./... | grep -vE "client/(clientset|informers|listers)"
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/tidb-operator/||'
Expand All @@ -29,17 +28,17 @@ TEST_COVER_PACKAGES:=go list ./pkg/... | grep -vE "pkg/client" | grep -vE "pkg/t
default: build

docker-push: docker backup-docker
docker push "${DOCKER_REGISTRY}/pingcap/tidb-operator:${IMAGE_TAG}"
docker push "${DOCKER_REGISTRY}/pingcap/tidb-backup-manager:${IMAGE_TAG}"
docker push "${DOCKER_REPO}/tidb-operator:${IMAGE_TAG}"
docker push "${DOCKER_REPO}/tidb-backup-manager:${IMAGE_TAG}"

ifeq ($(NO_BUILD),y)
docker:
@echo "NO_BUILD=y, skip build for $@"
else
docker: build
endif
docker build --tag "${DOCKER_REGISTRY}/pingcap/tidb-operator:${IMAGE_TAG}" images/tidb-operator
docker build --tag "${DOCKER_REGISTRY}/pingcap/tidb-backup-manager:${IMAGE_TAG}" images/tidb-backup-manager
docker build --tag "${DOCKER_REPO}/tidb-operator:${IMAGE_TAG}" images/tidb-operator
docker build --tag "${DOCKER_REPO}/tidb-backup-manager:${IMAGE_TAG}" images/tidb-backup-manager

build: controller-manager scheduler discovery admission-webhook apiserver backup-manager

Expand Down Expand Up @@ -67,10 +66,10 @@ backup-docker:
else
backup-docker: backup-manager
endif
docker build --tag "${DOCKER_REGISTRY}/pingcap/tidb-backup-manager:${IMAGE_TAG}" images/tidb-backup-manager
docker build --tag "${DOCKER_REPO}/tidb-backup-manager:${IMAGE_TAG}" images/tidb-backup-manager

e2e-docker-push: e2e-docker
docker push "${DOCKER_REGISTRY}/pingcap/tidb-operator-e2e:${IMAGE_TAG}"
docker push "${DOCKER_REPO}/tidb-operator-e2e:${IMAGE_TAG}"

ifeq ($(NO_BUILD),y)
e2e-docker:
Expand All @@ -86,7 +85,7 @@ endif
cp -r charts/tidb-cluster tests/images/e2e
cp -r charts/tidb-backup tests/images/e2e
cp -r manifests tests/images/e2e
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-operator-e2e:${IMAGE_TAG}" tests/images/e2e
docker build -t "${DOCKER_REPO}/tidb-operator-e2e:${IMAGE_TAG}" tests/images/e2e

e2e-build:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o tests/images/e2e/bin/ginkgo github.com/onsi/ginkgo/ginkgo
Expand All @@ -106,10 +105,10 @@ stability-test-build:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o tests/images/stability-test/bin/stability-test ./tests/cmd/stability

stability-test-docker: stability-test-build
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-operator-stability-test:${IMAGE_TAG}" tests/images/stability-test
docker build -t "${DOCKER_REPO}/tidb-operator-stability-test:${IMAGE_TAG}" tests/images/stability-test

stability-test-push: stability-test-docker
docker push "${DOCKER_REGISTRY}/pingcap/tidb-operator-stability-test:${IMAGE_TAG}"
docker push "${DOCKER_REPO}/tidb-operator-stability-test:${IMAGE_TAG}"

fault-trigger:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o tests/images/fault-trigger/bin/fault-trigger tests/cmd/fault-trigger/*.go
Expand Down Expand Up @@ -206,14 +205,14 @@ cli:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o tkctl cmd/tkctl/main.go

debug-docker-push: debug-build-docker
docker push "${DOCKER_REGISTRY}/pingcap/debug-launcher:latest"
docker push "${DOCKER_REGISTRY}/pingcap/tidb-control:latest"
docker push "${DOCKER_REGISTRY}/pingcap/tidb-debug:latest"
docker push "${DOCKER_REPO}/debug-launcher:latest"
docker push "${DOCKER_REPO}/tidb-control:latest"
docker push "${DOCKER_REPO}/tidb-debug:latest"

debug-build-docker: debug-build
docker build -t "${DOCKER_REGISTRY}/pingcap/debug-launcher:latest" misc/images/debug-launcher
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-control:latest" misc/images/tidb-control
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-debug:latest" misc/images/tidb-debug
docker build -t "${DOCKER_REPO}/debug-launcher:latest" misc/images/debug-launcher
docker build -t "${DOCKER_REPO}/tidb-control:latest" misc/images/tidb-control
docker build -t "${DOCKER_REPO}/tidb-debug:latest" misc/images/tidb-debug

debug-build:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o misc/images/debug-launcher/bin/debug-launcher misc/cmd/debug-launcher/main.go
Expand Down
16 changes: 8 additions & 8 deletions hack/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Usage: hack/e2e.sh [-h] -- [extra test args]
Environments:
PROVIDER Kubernetes provider, e.g. kind, gke, eks, defaults: kind
DOCKER_REGISTRY image docker registry
DOCKER_REPO docker image repo
IMAGE_TAG image tag
CLUSTER the name of e2e cluster, defaults: tidb-operator
KUBECONFIG path to the kubeconfig file, defaults: ~/.kube/config
Expand Down Expand Up @@ -172,7 +172,7 @@ if [ "${1:-}" == "--" ]; then
fi

PROVIDER=${PROVIDER:-kind}
DOCKER_REGISTRY=${DOCKER_REGISTRY:-localhost:5000}
DOCKER_REPO=${DOCKER_REPO:-localhost:5000/pingcap}
IMAGE_TAG=${IMAGE_TAG:-latest}
CLUSTER=${CLUSTER:-tidb-operator}
KUBECONFIG=${KUBECONFIG:-~/.kube/config}
Expand Down Expand Up @@ -204,7 +204,7 @@ SKIP_GINKGO=${SKIP_GINKGO:-}
RUNNER_SUITE_NAME=${RUNNER_SUITE_NAME:-}

echo "PROVIDER: $PROVIDER"
echo "DOCKER_REGISTRY: $DOCKER_REGISTRY"
echo "DOCKER_REPO: $DOCKER_REPO"
echo "IMAGE_TAG: $IMAGE_TAG"
echo "CLUSTER: $CLUSTER"
echo "KUBECONFIG: $KUBECONFIG"
Expand Down Expand Up @@ -248,8 +248,8 @@ function e2e::image_build() {
echo "info: skip building and pushing images"
return
fi
DOCKER_REGISTRY=$DOCKER_REGISTRY IMAGE_TAG=$IMAGE_TAG make docker
DOCKER_REGISTRY=$DOCKER_REGISTRY IMAGE_TAG=$IMAGE_TAG make e2e-docker
DOCKER_REPO=$DOCKER_REPO IMAGE_TAG=$IMAGE_TAG make docker
DOCKER_REPO=$DOCKER_REPO IMAGE_TAG=$IMAGE_TAG make e2e-docker
}

function e2e::__restart_docker() {
Expand Down Expand Up @@ -523,9 +523,9 @@ export AWS_ZONE
export IMAGE_TAG
export SKIP_GINKGO
export SKIP_IMAGE_LOAD
export TIDB_OPERATOR_IMAGE=$DOCKER_REGISTRY/pingcap/tidb-operator:${IMAGE_TAG}
export TIDB_BACKUP_MANAGER_IMAGE=$DOCKER_REGISTRY/pingcap/tidb-backup-manager:${IMAGE_TAG}
export E2E_IMAGE=$DOCKER_REGISTRY/pingcap/tidb-operator-e2e:${IMAGE_TAG}
export TIDB_OPERATOR_IMAGE=$DOCKER_REPO/tidb-operator:${IMAGE_TAG}
export TIDB_BACKUP_MANAGER_IMAGE=$DOCKER_REPO/tidb-backup-manager:${IMAGE_TAG}
export E2E_IMAGE=$DOCKER_REPO/tidb-operator-e2e:${IMAGE_TAG}
export PATH=$OUTPUT_BIN:$PATH

# Environments for kubetest2
Expand Down

0 comments on commit dbd721a

Please sign in to comment.