Skip to content

Commit

Permalink
add vtadmin docker image (vitessio#10543)
Browse files Browse the repository at this point in the history
* add-vtadmin-docker-image

Signed-off-by: Léopold Jacquot <[email protected]>

* env as function, update tests and code

Signed-off-by: Andrew Mason <[email protected]>
Signed-off-by: Léopold Jacquot <[email protected]>

* feat: fix remaining env usages to be function calls

Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Léopold Jacquot <[email protected]>

* add vtadmin build result in the bootstrap image

Signed-off-by: Léopold Jacquot <[email protected]>

* fix vtadmin web cleaning

Signed-off-by: Léopold Jacquot <[email protected]>

* add vtadmin docker image entrypoint

Signed-off-by: Léopold Jacquot <[email protected]>

* add the possibility to custom vtadmin web port in Docker image

Signed-off-by: Léopold Jacquot <[email protected]>

* fix vtadmin docker port

Signed-off-by: Léopold Jacquot <[email protected]>

* fix vtadmin entrypoint

Signed-off-by: Léopold Jacquot <[email protected]>

* set default vtadmin docker user as vitess

Signed-off-by: Léopold Jacquot <[email protected]>

* do not build vtadmin frontend in the bootstrap image

Signed-off-by: Léopold Jacquot <[email protected]>

* build vtadmin frontend only in vtadmin docker image

Signed-off-by: Léopold Jacquot <[email protected]>

* vtadmin replace sed and custom entrypoint with config.js file

Signed-off-by: Léopold Jacquot <[email protected]>

* remove vitess web files in lite docker image

Signed-off-by: Léopold Jacquot <[email protected]>

* move vtadmin config into a specific directory

Signed-off-by: Léopold Jacquot <[email protected]>

* restore vtadmin web file in mysql57 lite docker image

Signed-off-by: Léopold Jacquot <[email protected]>

Co-authored-by: Andrew Mason <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
  • Loading branch information
3 people authored Jun 26, 2022
1 parent 50f8ab1 commit 13c7bcc
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 151 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
55 changes: 55 additions & 0 deletions docker/k8s/vtadmin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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} as node

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

# 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

# install/build/clean web dependencies
RUN npm --prefix /vt/web/vtadmin ci && \
npm run --prefix /vt/web/vtadmin build

# 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

USER vitess

VOLUME /vt/web/vtadmin/build/config

CMD ["/bin/bash", "-c", "/vt/web/vtadmin/node_modules/.bin/serve --no-clipboard -l $VTADMIN_WEB_PORT -s /vt/web/vtadmin/build"]

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 13c7bcc

Please sign in to comment.