-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (72 loc) · 3.47 KB
/
Dockerfile
File metadata and controls
92 lines (72 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 2025 The Vitess Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Build the Vitess Go binaries
FROM golang:1.26.3-trixie@sha256:d08bf3ed2bd263088ca8e23fefaf10f1b71769f6932f0a4017ba28d2a5baf001 AS go-builder
# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
# Allows docker builds to set the BUILD_GIT_BRANCH
ARG BUILD_GIT_BRANCH
# Allows docker builds to set the BUILD_GIT_REV
ARG BUILD_GIT_REV
# Allows docker builds to set the BUILD_TIME
ARG BUILD_TIME
WORKDIR /vt/src/vitess.io/vitess
# Create vitess user
RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot /home/vitess
RUN chown -R vitess:vitess /vt /home/vitess
USER vitess
# Copy go.mod/go.sum and install dependencies separately.
COPY --chown=vitess:vitess go.mod go.sum /vt/src/vitess.io/vitess/
RUN go mod download
# Copy the rest of the source and build the binaries.
COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess
RUN make install PREFIX=/vt/install NOVTADMINBUILD=1
# Build vtadmin separately.
FROM node:25-trixie-slim@sha256:6517bd703147da68ecd657ab1951377c839bcf667c86717ab65ff31600685341 AS vtadmin-builder
WORKDIR /vt/web/vtadmin
# Copy package.json/package-lock.json and install dependencies separately.
COPY web/vtadmin/package.json web/vtadmin/package-lock.json /vt/web/vtadmin/
RUN npm ci
# Copy the rest of the source and build the static files.
COPY web/vtadmin/ /vt/web/vtadmin/
RUN VITE_VTADMIN_API_ADDRESS="http://localhost:14200" \
VITE_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS="true" \
npm run build
# Build the final image with the minimum Go binaries + static files.
FROM debian:trixie-slim@sha256:109e2c65005bf160609e4ba6acf7783752f8502ad218e298253428690b9eaa4b
# Install locale required for mysqlsh
RUN apt-get update && apt-get install -y locales tar \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen en_US.UTF-8
# Install dependencies
COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh
RUN /vt/dist/install_dependencies.sh mysql84
# Set up Vitess user and directory tree.
RUN groupadd -r vitess && useradd -r -g vitess vitess
RUN mkdir -p /vt/vtdataroot /home/vitess && chown -R vitess:vitess /vt /home/vitess
# Set up Vitess environment (just enough to run pre-built Go binaries)
ENV VTROOT=/vt
ENV VTDATAROOT=/vt/vtdataroot
ENV PATH=$VTROOT/bin:$PATH
# Copy artifacts from builder layers.
COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=go-builder --chown=vitess:vitess /vt/install /vt
COPY --from=go-builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin
COPY --from=vtadmin-builder --chown=vitess:vitess /vt/web/vtadmin/build /vt/web/vtadmin/build
COPY --from=go-builder --chown=vitess:vitess /vt/src/vitess.io/vitess/config/init_db.sql /vt/config/
COPY --from=go-builder --chown=vitess:vitess /vt/src/vitess.io/vitess/config/mycnf /vt/config/
# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
USER vitess