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

Release CentOS7 dockerfile [skip pd_pr] #1468

Merged
merged 1 commit into from
Jan 13, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/test-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test-cross-platform-image:
test-build-docker-image:
runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand All @@ -29,6 +29,7 @@ jobs:
- name: Build
uses: docker/build-push-action@v3
with:
file: ./dockerfiles/centos7.Dockerfile
context: .
# Currently github action runner only supports linux/amd64, it take a lot of time to build multi-arch image.
# So we only build amd64 image for now.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

backend_integration:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
strategy:
matrix:
tidb_version: [nightly, ^6.0, ^5.4, ^5.0]
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ If you want to develop docker image locally 🤔.

# Or, if you want to build cross-platform image and push it to your dev docker registry, run:
REPOSITORY=your-tidb-dashboard-repository make docker-build-and-push-image

# Or, if you want to build centos7 based image, run:
DOCKERFILE=./dockerfiles/centos7.Dockerfile make docker-build-image-locally-arm64

# Finally, if you update npm modules or go modules, and want to disable docker layer cache to force rebuild, set NO_CACHE="--pull --no-cache" before make command. For example:
NO_CACHE="--pull --no-cache" make docker-build-image-locally-amd64
Expand All @@ -148,7 +151,7 @@ If you want to develop docker image locally 🤔.

4. Access TiDB Dashboard at [http://localhost:12333/dashboard](http://localhost:12333/dashboard).

> Dashboard in PD can be accessed at [http://localhost:2379/dashboard](http://localhost:2379/dashboard).
> The old Dashboard **_in PD_** can be accessed at [http://localhost:2379/dashboard](http://localhost:2379/dashboard).

## Contribution flow

Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ IMAGE ?= $(REPOSITORY):$(RELEASE_VERSION)
AMD64 := linux/amd64
ARM64 := linux/arm64
PLATFORMS := $(AMD64),$(ARM64)
DOCKERFILE ?= ./dockerfiles/alpine316.Dockerfile
# If you want to build with no cache (after update go module, npm module, etc.), set "NO_CACHE=--pull --no-cache".
NO_CACHE ?=

Expand Down Expand Up @@ -136,16 +137,16 @@ package: embed_ui_assets server

.PHONY: docker-build-and-push-image # For locally dev, set IMAGE to your dev docker registry.
docker-build-and-push-image: clean
docker buildx build ${NO_CACHE} --push -t $(IMAGE) --platform $(PLATFORMS) .
docker buildx build ${NO_CACHE} --push -t $(IMAGE) --platform $(PLATFORMS) -f $(DOCKERFILE) .

.PHONY: docker-build-image-locally-amd64
docker-build-image-locally-amd64: clean
docker buildx build ${NO_CACHE} --load -t $(IMAGE) --platform $(AMD64) .
docker buildx build ${NO_CACHE} --load -t $(IMAGE) --platform $(AMD64) -f $(DOCKERFILE) .
docker run --rm $(IMAGE) -v

.PHONY: docker-build-image-locally-arm64
docker-build-image-locally-arm64: clean
docker buildx build ${NO_CACHE} --load -t $(IMAGE) --platform $(ARM64) .
docker buildx build ${NO_CACHE} --load -t $(IMAGE) --platform $(ARM64) -f $(DOCKERFILE) .
docker run --rm $(IMAGE) -v

.PHONY: run # please ensure that tiup playground is running in the background.
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile → dockerfiles/alpine316.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ RUN mkdir -p /go/src/github.com/pingcap/tidb-dashboard/ui
WORKDIR /go/src/github.com/pingcap/tidb-dashboard

# Cache go module dependencies.
COPY go.mod .
COPY go.sum .
COPY ../go.mod .
COPY ../go.sum .
RUN GO111MODULE=on go mod download

# Cache go tools.
COPY ../scripts scripts/
RUN scripts/install_go_tools.sh

# Cache npm dependencies.
WORKDIR /go/src/github.com/pingcap/tidb-dashboard/ui
COPY ui/pnpm-lock.yaml .
COPY ../ui/pnpm-lock.yaml .
RUN pnpm fetch

# Build.
WORKDIR /go/src/github.com/pingcap/tidb-dashboard
COPY . .
COPY .. .
RUN make package PNPM_INSTALL_TAGS=--offline

FROM alpine:3.16
Expand Down
51 changes: 51 additions & 0 deletions dockerfiles/centos7.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM centos:7 as builder

RUN yum -y update
RUN yum -y groupinstall "Development Tools"

# Install golang.
RUN export ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
export GO_VERSION=1.19.5 && \
curl -OL https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz && \
tar -C / -xzf go$GO_VERSION.linux-$ARCH.tar.gz && \
rm -f go$GO_VERSION.linux-$ARCH.tar.gz
ENV PATH /go/bin:$PATH
ENV GOROOT /go

# Install nodejs.
RUN curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -
RUN yum -y install nodejs
RUN npm install -g pnpm

# Install java.
RUN yum -y install java-11-openjdk

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

# Cache go module dependencies.
COPY ../go.mod .
COPY ../go.sum .
RUN GO111MODULE=on go mod download

# Cache go tools.
COPY ../scripts scripts/
RUN scripts/install_go_tools.sh

# Cache npm dependencies.
WORKDIR /go/src/github.com/pingcap/tidb-dashboard/ui
COPY ../ui/pnpm-lock.yaml .
RUN pnpm fetch

# Build.
WORKDIR /go/src/github.com/pingcap/tidb-dashboard
COPY .. .
RUN make package PNPM_INSTALL_TAGS=--offline

FROM centos:8

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

EXPOSE 12333

ENTRYPOINT ["/tidb-dashboard"]
File renamed without changes.
6 changes: 3 additions & 3 deletions scripts/_inc/run_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROJECT_DIR="$(dirname "$0")/.."
BIN="${PROJECT_DIR}/bin"

start_tidb() {
echo "+ Waiting for TiDB start..."
echo "+ Waiting for TiDB start, for at most 10 min..."

rm -rf $INTEGRATION_LOG_PATH
TIDB_VERSION=${1:-latest}
Expand All @@ -30,11 +30,11 @@ ensure_tidb() {
i=1
while ! grep "CLUSTER START SUCCESSFULLY" $INTEGRATION_LOG_PATH; do
i=$((i+1))
if [ "$i" -gt 20 ]; then
if [ "$i" -gt 60 ]; then
echo 'Failed to start TiDB'
return 1
fi
sleep 5
sleep 10
done
}

Expand Down