Skip to content

Commit

Permalink
dockerfile: optimize dockerfile (#49559)
Browse files Browse the repository at this point in the history
close #49071
  • Loading branch information
purelind authored Dec 20, 2023
1 parent 7d33d0d commit 18d6980
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git/
bazel-bin/
bazel-out/
bazel-tidb/
Expand Down
27 changes: 12 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The current dockerfile is only used for development purposes. If used in a
# production environment, please refer to https://github.com/PingCAP-QE/artifacts/blob/main/dockerfiles/cd/builders/tidb/Dockerfile.

# Builder image
FROM rockylinux:9 as builder

ENV GOLANG_VERSION 1.21.5
ENV ARCH amd64
ENV GOLANG_DOWNLOAD_URL https://dl.google.com/go/go$GOLANG_VERSION.linux-$ARCH.tar.gz
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
RUN yum update -y && yum groupinstall 'Development Tools' -y \
&& curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

COPY . /tidb
FROM golang:1.21 as builder
WORKDIR /tidb

COPY . .

ARG GOPROXY
RUN export GOPROXY=${GOPROXY} && cd /tidb && make server
ENV GOPROXY ${GOPROXY}

RUN make server


FROM rockylinux:9-minimal

Expand Down
20 changes: 7 additions & 13 deletions Dockerfile.enterprise
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The current dockerfile is only used for development purposes.
# Builder image
FROM rockylinux:9 as builder
FROM golang:1.21 as builder
WORKDIR /tidb

ENV GOLANG_VERSION 1.21.5
ENV ARCH amd64
ENV GOLANG_DOWNLOAD_URL https://dl.google.com/go/go$GOLANG_VERSION.linux-$ARCH.tar.gz
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
RUN yum update -y && yum groupinstall 'Development Tools' -y \
&& curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz
COPY . .

COPY . /tidb
ARG GOPROXY
RUN export GOPROXY=${GOPROXY} && cd /tidb && make enterprise-server-build
ENV GOPROXY ${GOPROXY}

RUN make enterprise-server-build

FROM rockylinux:9-minimal

Expand Down

0 comments on commit 18d6980

Please sign in to comment.