Skip to content

Commit 645e893

Browse files
committed
*: 1. Add leader postStart,preStop cmd in xenon container
2. Add leaderstop cmd in xenon conf 3. Adjust project structure
1 parent 0c496e3 commit 645e893

File tree

14 files changed

+705
-28
lines changed

14 files changed

+705
-28
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ COPY go.mod go.mod
77
COPY go.sum go.sum
88
# cache deps before building and copying source so that we don't need to re-download as much
99
# and so that source changes don't invalidate our downloaded layer
10-
# RUN go env -w GOPROXY=https://goproxy.cn,direct; \
11-
# go mod download
10+
# RUN go env -w GOPROXY=https://goproxy.cn,direct
1211
RUN go mod download
1312

1413
# Copy the go source

Dockerfile.sidecar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COPY go.sum go.sum
1111

1212
# cache deps before building and copying source so that we don't need to re-download as much
1313
# and so that source changes don't invalidate our downloaded layer
14-
# RUN go env -w GOPROXY=https://goproxy.cn,direct; \
14+
# RUN go env -w GOPROXY=https://goproxy.cn,direct;
1515
# go mod download
1616
RUN go mod download
1717

build/mysql/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM golang:1.16 as builder
2+
3+
WORKDIR /
4+
# Copy the Go Modules manifests
5+
COPY go.mod go.mod
6+
COPY go.sum go.sum
7+
# cache deps before building and copying source so that we don't need to re-download as much
8+
# and so that source changes don't invalidate our downloaded layer
9+
RUN go env -w GOPROXY=https://goproxy.cn,direct;
10+
# go mod download
11+
RUN go mod download
12+
13+
# Copy the go source
14+
COPY cmd/healthcheck/main.go cmd/healthcheck/main.go
15+
COPY utils/ utils/
16+
COPY internal/ internal/
17+
# COPY api/ api/
18+
# COPY mysqlcluster/ mysqlcluster/
19+
20+
# Build
21+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/healthcheck cmd/healthcheck/main.go
22+
23+
FROM percona/percona-server:5.7.34
24+
25+
COPY --from=builder /bin/healthcheck /healthcheck

build/xenon/Dockerfile

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
1-
FROM golang:1.16 as builder
1+
##############################################################################
2+
# Build Xenon
3+
###############################################################################
24

3-
WORKDIR /
4-
# Copy the Go Modules manifests
5-
COPY go.mod go.mod
6-
COPY go.sum go.sum
7-
# cache deps before building and copying source so that we don't need to re-download as much
8-
# and so that source changes don't invalidate our downloaded layer
9-
RUN go env -w GOPROXY=https://goproxy.cn,direct;
10-
#     go mod download
11-
RUN  go mod download
5+
FROM golang:1.16 as builder
126

7+
ARG XENON_BRANCH=origin_test
8+
RUN go env -w GOPROXY=https://goproxy.cn,direct && go env -w GO111MODULE=off;
9+
RUN set -ex; \
10+
mkdir -p /go/src/github.com/radondb; \
11+
cd /go/src/github.com/radondb; \
12+
git clone --branch $XENON_BRANCH https://github.com/zhl003/xenon.git; \
13+
cd xenon; \
14+
make build
15+
WORKDIR /workspace
1316
# Copy the go source
1417
COPY cmd/xenon/main.go cmd/xenon/main.go
1518
COPY utils/ utils/
16-
19+
COPY go.mod go.mod
20+
COPY go.sum go.sum
21+
RUN go env -w GO111MODULE=on && go mod download
1722
# Build
18-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/xenonchecker cmd/xenon/main.go
23+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o xenonchecker cmd/xenon/main.go
24+
###############################################################################
25+
# Docker image for Xenon
26+
###############################################################################
27+
28+
FROM alpine:3.13
1929

20-
FROM radondb/xenon:1.1.5-alpha
30+
RUN set -ex \
31+
&& addgroup -g 1001 mysql && adduser -u 1001 -g 1001 -S mysql \
32+
&& apk add --no-cache curl bash jq \
33+
&& mkdir -p /etc/xenon /var/lib/xenon /lib64 \
34+
&& ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 \
35+
&& echo "/etc/xenon/xenon.json" > /config.path \
36+
# allow to change config files
37+
&& chown -R 1001:1001 /etc/xenon /var/lib/xenon
38+
39+
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenon /usr/local/bin/xenon
40+
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenoncli /usr/local/bin/xenoncli
41+
COPY --from=builder /workspace/xenonchecker /xenonchecker
42+
USER 1001
43+
WORKDIR /
44+
EXPOSE 8801
45+
VOLUME ["/var/lib/xenon", "/etc/xenon"]
2146

22-
COPY --from=builder /bin/xenonchecker /xenonchecker
47+
ENTRYPOINT ["xenon"]
48+
CMD ["-c", "/etc/xenon/xenon.json"]

0 commit comments

Comments
 (0)