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

build from source locally #3

Merged
merged 6 commits into from
Mar 14, 2018
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
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,30 @@ Or if you use Mac, you can use homebrew to install Helm by `brew install kuberne
```bash
$ git clone https://github.com/pingcap/tidb-docker-compose.git
$ cd tidb-docker-compose
$ cp compose/values.yaml values.yaml
$ vi values.yaml # custom cluster size, docker image, port mapping etc
$ helm template -f values.yaml compose > generated-docker-compose.yaml
$ vi compose/values.yaml # custom cluster size, docker image, port mapping etc
$ helm template compose > generated-docker-compose.yaml
$ docker-compose -f generated-docker-compose.yaml up -d
```

You can build docker image yourself for development test.

* Build locally
* Build from binary

For pd, tikv and tidb, leave their `image` field empty and set their `buildFrom` field to `local`. And then copy their binary files to pd/bin/pd-server, tikv/bin/tikv-server and tidb/bin/tidb-server.
For tidbVision, leave its `image` field empty and set its `buildFrom` field to `local`. And then copy tidb-vision repo to tidb-vision/tidb-vision.
For pd, tikv and tidb, comment their `image` and `buildPath` fields out. And then copy their binary files to pd/bin/pd-server, tikv/bin/tikv-server and tidb/bin/tidb-server.

* Build from remote source
These binary files can be built locally or downloaded from https://download.pingcap.org/tidb-latest-linux-amd64.tar.gz

Leave pd, tikv, tidb and tidbVision `image` field empty and set their `buildFrom` field to `remote`
For tidbVision, comment its `image` and `buildPath` fields out. And then copy tidb-vision repo to tidb-vision/tidb-vision.

[tidb-vision](https://github.com/pingcap/tidb-vision) is a visiualization page of TiDB Cluster, it's WIP project and can be disabled by leaving `tidbVision` empty.
* Build from source

Leave pd, tikv, tidb and tidbVision `image` field empty and set their `buildPath` field to their source directory.

For example, if your local tikv source directory is $GOPATH/src/github.com/pingcap/tikv, just set tikv `buildPath` to `$GOPATH/src/github.com/pingcap/tikv`

*Note:* Compiling tikv from source consumes lots of memory, memory of Docker for Mac needs to be adjusted to greater than 6GB

[tidb-vision](https://github.com/pingcap/tidb-vision) is a visiualization page of TiDB Cluster, it's WIP project and can be disabled by commenting `tidbVision` out.

### Access TiDB cluster

Expand Down
46 changes: 8 additions & 38 deletions compose/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ services:
{{- else }}
image: pd:latest
build:
context: ./pd
{{- if eq $.Values.pd.buildFrom "remote" }}
dockerfile: Dockerfile.src
args:
repo: {{ $.Values.pd.repo | default "https://github.com/pingcap/pd.git" }}
branch: {{ $.Values.pd.branch | default "master" }}
{{- else }}
dockerfile: Dockerfile.bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you can keep the dockerfile parameter. If this parameter is not set, set the default value to Dockerfile.

{{- end }}
context: {{ $.Values.pd.buildPath | default "./pd" }}
dockerfile: {{ $.Values.pd.dockerfile | default "Dockerfile" }}
{{- end }}
ports:
- "2379"
Expand Down Expand Up @@ -62,17 +55,8 @@ services:
{{- else }}
image: tikv:latest
build:
context: ./tikv
{{- if eq $.Values.tikv.buildFrom "remote" }}
dockerfile: Dockerfile.src
args:
repo: {{ $.Values.tikv.repo | default "https://github.com/pingcap/tikv.git" }}
branch: {{ $.Values.tikv.branch | default "master" }}
rustupVersion: {{ $.Values.rustupVersion | default "1.7.0" }}
rust_toolchain: {{ $.Values.rustToolChain | default "nightly-2017-08-09" }}
{{- else }}
dockerfile: Dockerfile.bin
{{- end }}
context: {{ $.Values.tikv.buildPath | default "./tikv" }}
dockerfile: {{ $.Values.tikv.dockerfile | default "Dockerfile" }}
{{- end }}
volumes:
- ./config/tikv.toml:/tikv.toml:ro
Expand Down Expand Up @@ -102,15 +86,8 @@ services:
{{- else }}
image: tidb:latest
build:
context: ./tidb
{{- if eq .Values.tidb.buildFrom "remote" }}
dockerfile: Dockerfile.src
args:
repo: {{ .Values.tidb.repo | default "https://github.com/pingcap/tidb.git" }}
branch: {{ .Values.tidb.branch | default "master" }}
{{- else }}
dockerfile: Dockerfile.bin
{{- end }}
context: {{ .Values.tidb.buildPath | default "./tidb" }}
dockerfile: {{ .Values.tidb.dockerfile | default "Dockerfile" }}
{{- end }}
ports:
{{- if .Values.tidb.mysqlPort }}
Expand Down Expand Up @@ -149,15 +126,8 @@ services:
{{- else }}
image: tidb-vision:latest
build:
context: ./tidb-vision
{{- if eq .Values.tidbVision.buildFrom "remote" }}
dockerfile: Dockerfile.remote
args:
repo: {{ .Values.tidbVision.repo | default "https://github.com/pingcap/tidb-vision.git" }}
branch: {{ .Values.tidbVision.branch | default "master" }}
{{- else }}
dockerfile: Dockerfile.local
{{- end }}
context: {{ .Values.tidbVision.buildPath | default "./tidb-vision" }}
dockerfile: {{ .Values.tidbVision.dockerfile | default "Dockerfile" }}
{{- end }}
environment:
# TODO: we use only one pd endpoint
Expand Down
31 changes: 23 additions & 8 deletions compose/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,39 @@ data_dir: ./data
pd:
size: 3
image: pingcap/pd:latest
# build from local binary or remote source if image is empty
buildFrom: local # local | remote

# If you want to build pd image from source, leave image empty and specify pd source directory
# and its dockerfile name
# buildPath: ./pd
# dockerfile: Dockerfile

tikv:
size: 3
image: pingcap/tikv:latest
# build from local binary or remote source if image is empty
buildFrom: local # local | remote

# If you want to build tikv image from source, leave image empty and specify tikv source directory
# and its dockerfile name
# buildPath: ./tikv
# dockerfile: Dockerfile

tidb:
image: pingcap/tidb:latest
# build from local binary or remote source if image is empty
buildFrom: local # local | remote

# If you want to build tidb image from source, leave image empty and specify tidb source directory
# and its dockerfile name
# buildPath: ./tidb
# dockerfile: Dockerfile
mysqlPort: "4000"
statusPort: "10080"

# comment this out to disable tidb-vision
tidbVision:
image: pingcap/tidb-vision:latest
# build from local source or remote source if image is empty
buildFrom: local # local | remote

# If you want to build tidb-vision image from source, leave image empty and specify tidb-vision source directory
# and its dockerfile name
# buildPath: ./tidb-vision
# dockerfile: Dockerfile
port: "8010"

grafana:
Expand All @@ -36,5 +49,7 @@ prometheus:
image: prom/prometheus:v2.0.0
port: "9090"

# This is used to import tidb monitor dashboard templates to grafana
# this container runs only once and keep running until templates imported successfully
dashboardInstaller:
image: pingcap/tidb-dashboard-installer:v1.0.0
File renamed without changes.
25 changes: 0 additions & 25 deletions pd/Dockerfile.src

This file was deleted.

File renamed without changes.
17 changes: 0 additions & 17 deletions tidb-vision/Dockerfile.remote

This file was deleted.

File renamed without changes.
25 changes: 0 additions & 25 deletions tidb/Dockerfile.src

This file was deleted.

File renamed without changes.
38 changes: 0 additions & 38 deletions tikv/Dockerfile.src

This file was deleted.