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

Docker image support and misc. improvements #1439

Merged
merged 20 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 36 additions & 0 deletions .github/workflows/test-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test Docker Image
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test-amd64-image:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Checkout code
uses: actions/checkout@v3
- name: Make
run: make docker-image-test-amd64
test-arm64-image:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Checkout code
uses: actions/checkout@v3
- name: Make
run: make docker-image-test-arm64
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ jobs:
include:
- feature_version: 6.0.0 # You must ensure feature_version and tidb_version is matching!
tidb_version: nightly
without_ngm: false
without_ngm: true
- feature_version: 6.0.0
tidb_version: nightly
without_ngm: true
SabaPing marked this conversation as resolved.
Show resolved Hide resolved
- feature_version: 6.0.0
tidb_version: ^6.0
without_ngm: false
without_ngm: true
- feature_version: 6.0.0
tidb_version: ^6.0
without_ngm: true
SabaPing marked this conversation as resolved.
Show resolved Hide resolved
- feature_version: 5.4.0
tidb_version: ^5.4
without_ngm: false
without_ngm: true
- feature_version: 5.0.0
tidb_version: ^5.0
without_ngm: false
without_ngm: true
name: E2E - TiDB@${{ matrix.tidb_version }}${{ !matrix.without_ngm && '+ngm' || '' }}
steps:
- name: Checkout code
Expand Down
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.18-alpine as builder

RUN apk add --no-cache \
make \
git \
bash \
curl \
findutils \
gcc \
libc-dev

RUN mkdir -p /go/src/github.com/pingcap/tidb-dashboard
WORKDIR /go/src/github.com/pingcap/tidb-dashboard

# Cache dependencies
COPY go.mod .
COPY go.sum .

RUN GO111MODULE=on go mod download

COPY . .

RUN make server
SabaPing marked this conversation as resolved.
Show resolved Hide resolved

FROM alpine

COPY --from=builder /go/src/github.com/pingcap/tidb-dashboard/bin/tidb-dashboard /tidb-dashboard

EXPOSE 12333

ENTRYPOINT ["/tidb-dashboard"]
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ WITHOUT_NGM ?= false

E2E_SPEC ?=

RELEASE_VERSION := $(shell grep -v '^\#' ./release-version)

ifeq ($(UI),1)
BUILD_TAGS += ui_server
endif

LDFLAGS += -X "$(DASHBOARD_PKG)/pkg/utils/version.InternalVersion=$(shell grep -v '^\#' ./release-version)"
LDFLAGS += -X "$(DASHBOARD_PKG)/pkg/utils/version.InternalVersion=$(RELEASE_VERSION)"
LDFLAGS += -X "$(DASHBOARD_PKG)/pkg/utils/version.Standalone=Yes"
LDFLAGS += -X "$(DASHBOARD_PKG)/pkg/utils/version.PDVersion=N/A"
LDFLAGS += -X "$(DASHBOARD_PKG)/pkg/utils/version.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
Expand Down Expand Up @@ -112,6 +114,25 @@ ifeq ($(UI),1)
endif
go build -o bin/tidb-dashboard -ldflags '$(LDFLAGS)' -tags "${BUILD_TAGS}" cmd/tidb-dashboard/main.go

IMAGE := pingcap/tidb-dashboard:$(RELEASE_VERSION)
AMD64 := linux/amd64
ARM64 := linux/arm64
PLATFORMS := $(AMD64),$(ARM64)

.PHONY: docker-image
docker-image:
docker buildx build --push --no-cache -t $(IMAGE) --platform $(PLATFORMS) .

.PHONY: docker-image-test-amd64
docker-image-test-amd64:
docker buildx build --load --no-cache -t $(IMAGE) --platform $(AMD64) .
docker run --rm -it $(IMAGE) -v

.PHONY: docker-image-test-arm64
docker-image-test-arm64:
docker buildx build --load --no-cache -t $(IMAGE) --platform $(ARM64) .
docker run --rm -it $(IMAGE) -v

.PHONY: run
run:
bin/tidb-dashboard --debug --experimental --feature-version "$(FEATURE_VERSION)" --host 0.0.0.0
12 changes: 6 additions & 6 deletions cmd/tidb-dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func NewCLIConfig() *DashboardCLIConfig {

showVersion := flag.BoolP("version", "v", false, "print version information and exit")

clusterCaPath := flag.String("cluster-ca", "", "path of file that contains list of trusted SSL CAs")
clusterCertPath := flag.String("cluster-cert", "", "path of file that contains X509 certificate in PEM format")
clusterKeyPath := flag.String("cluster-key", "", "path of file that contains X509 key in PEM format")
clusterCaPath := flag.String("cluster-ca", "", "(TLS between components of the TiDB cluster) path of file that contains list of trusted SSL CAs")
clusterCertPath := flag.String("cluster-cert", "", "(TLS between components of the TiDB cluster) path of file that contains X509 certificate in PEM format")
clusterKeyPath := flag.String("cluster-key", "", "(TLS between components of the TiDB cluster) path of file that contains X509 key in PEM format")

tidbCaPath := flag.String("tidb-ca", "", "path of file that contains list of trusted SSL CAs")
tidbCertPath := flag.String("tidb-cert", "", "path of file that contains X509 certificate in PEM format")
tidbKeyPath := flag.String("tidb-key", "", "path of file that contains X509 key in PEM format")
tidbCaPath := flag.String("tidb-ca", "", "(TLS for MySQL client) path of file that contains list of trusted SSL CAs")
tidbCertPath := flag.String("tidb-cert", "", "(TLS for MySQL client) path of file that contains X509 certificate in PEM format")
tidbKeyPath := flag.String("tidb-key", "", "(TLS for MySQL client) path of file that contains X509 key in PEM format")

// debug for keyvisual,hide help information
flag.Int64Var(&cfg.KVFileStartTime, "keyviz-file-start", 0, "(debug) start time for file range in file mode")
Expand Down