Skip to content

Commit

Permalink
add-vtadmin-docker-image
Browse files Browse the repository at this point in the history
Signed-off-by: Léopold Jacquot <[email protected]>
  • Loading branch information
L3o-pold committed Jun 22, 2022
1 parent 070b2b5 commit ed78100
Show file tree
Hide file tree
Showing 30 changed files with 145 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ releases
/vthook/
/bin/
/vtdataroot/
/web/vtadmin/node_modules
/web/vtadmin/build
15 changes: 15 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
ARG bootstrap_version=9
ARG image="vitess/bootstrap:${bootstrap_version}-mysql57"

FROM node:16-bullseye-slim as node

COPY web/vtadmin /vt/web/vtadmin

# install/build/clean web dependencies
RUN npm --prefix /vt/web/vtadmin ci && \
npm run --prefix /vt/web/vtadmin build && \
find /vt/web/vtadmin -name "*" \
-not -path "/vt/web/vtadmin" \
-not -path "/vt/web/vtadmin/build*" \
-not -path "/vt/web/vtadmin/node_modules" \
-not -path "/vt/web/vtadmin/node_modules/.bin" \
-not -path "/vt/web/vtadmin/node_modules/.bin/serve" | xargs rm -rf

FROM "${image}"

# Allows some docker builds to disable CGO
Expand All @@ -34,6 +48,7 @@ ARG BUILD_NUMBER

# Re-copy sources from working tree
USER root
COPY --from=node /vt/web/vtadmin /vt/src/vitess.io/vitess/web/vtadmin
COPY . /vt/src/vitess.io/vitess

# Build Vitess
Expand Down
43 changes: 43 additions & 0 deletions docker/k8s/vtadmin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2022 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.

ARG VT_BASE_VER=latest
ARG DEBIAN_VER=bullseye-slim

FROM vitess/k8s:${VT_BASE_VER} AS k8s

FROM node:16-${DEBIAN_VER}

# Set up Vitess environment (just enough to run pre-built Go binaries)
ENV VTROOT /vt

# Prepare directory structure.
RUN mkdir -p /vt/bin && \
mkdir -p /vt/web && mkdir -p /vtdataroot

# Copy binaries
COPY --from=k8s /vt/bin/vtadmin /vt/bin/

# Copy certs to allow https calls
COPY --from=k8s /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

# copy web admin files
COPY --from=k8s /vt/web/vtadmin /vt/web/vtadmin

# add vitess user/group and add permissions
RUN deluser node && \
groupadd -r --gid 2000 vitess && \
useradd -r -g vitess --uid 1000 vitess && \
chown -R vitess:vitess /vt && \
chown -R vitess:vitess /vtdataroot
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ENV MYSQL_FLAVOR MariaDB103
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.mariadb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ENV MYSQL_FLAVOR MariaDB
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.mariadb103
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ENV MYSQL_FLAVOR MariaDB103
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.percona57
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ENV PATH $VTROOT/bin:$PATH
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.percona80
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.testing
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ENV PATH $VTROOT/bin:$PATH
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

# Create mount point for actual data (e.g. MySQL data dir)
VOLUME /vt/vtdataroot
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi7.mysql57
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ ENV PATH $VTROOT/bin:$PATH
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi7.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi7.percona57
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ENV PATH $VTROOT/bin:$PATH
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi7.percona80
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi8.arm64.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
1 change: 1 addition & 0 deletions docker/lite/Dockerfile.ubi8.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ENV MYSQL_FLAVOR MySQL80
# Copy artifacts from builder layer.
COPY --from=builder --chown=vitess:vitess /vt/install /vt
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/orchestrator /vt/web/orchestrator
COPY --from=builder --chown=vitess:vitess /vt/src/vitess.io/vitess/web/vtadmin /vt/web/vtadmin

RUN mkdir -p /licenses
COPY LICENSE /licenses
Expand Down
5 changes: 5 additions & 0 deletions docker/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ do
docker push vitess/k8s:$vt_base_version-$debian_version
if [[ $debian_version == $default_debian_version ]]; then docker push vitess/k8s:$vt_base_version; fi

docker build --platform linux/amd64 --build-arg VT_BASE_VER=$vt_base_version --build-arg DEBIAN_VER=$debian_version-slim -t vitess/vtadmin:$vt_base_version-$debian_version k8s/vtadmin
docker tag vitess/vtadmin:$vt_base_version-$debian_version vitess/vtadmin:$vt_base_version
docker push vitess/vtadmin:$vt_base_version-$debian_version
if [[ $debian_version == $default_debian_version ]]; then docker push vitess/vtadmin:$vt_base_version; fi

docker build --platform linux/amd64 --build-arg VT_BASE_VER=$vt_base_version --build-arg DEBIAN_VER=$debian_version-slim -t vitess/vtgate:$vt_base_version-$debian_version k8s/vtgate
docker tag vitess/vtgate:$vt_base_version-$debian_version vitess/vtgate:$vt_base_version
docker push vitess/vtgate:$vt_base_version-$debian_version
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtadmin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Then, you can run `make build`, and run `./bin/vtadmin` with any flags you need

### Building and running `vtadmin-web`

Make sure you are using node version 12.x.
Make sure you are using node version 16.x.

Then, you may run:

Expand Down
Loading

0 comments on commit ed78100

Please sign in to comment.