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

求一个完整的Dockerfile #611

Open
redmangame opened this issue Jul 10, 2021 · 1 comment
Open

求一个完整的Dockerfile #611

redmangame opened this issue Jul 10, 2021 · 1 comment

Comments

@redmangame
Copy link

官方的运行部起来

@xchenhao
Copy link

可以用这个

FROM golang:1.15-alpine3.12 as builder

ARG goproxy

COPY . /go/src/github.com/flike/kingshard
RUN cd /go/src/github.com/flike/kingshard \
  && GO111MODULE=off GOPROXY=$goproxy GOOS=linux CGO_ENABLED=0 go install -v ./vendor/golang.org/x/tools/cmd/goyacc \
  && /go/bin/goyacc -o ./sqlparser/sql.go ./sqlparser/sql.y \
  && GO111MODULE=off GOPROXY=$goproxy GOOS=linux CGO_ENABLED=0 go install -v ./cmd/kingshard

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
  && apk --update add --no-cache tzdata git

FROM scratch

COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/passwd /etc/
COPY --from=builder /go/bin/kingshard /bin/

WORKDIR /

# server listen addr
EXPOSE 3306
# the web api server
EXPOSE 9797

USER nobody

ENTRYPOINT ["/bin/kingshard"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants