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
1417COPY cmd/xenon/main.go cmd/xenon/main.go
1518COPY 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