Skip to content

Commit

Permalink
[YottaDB/UI/YDBGUI#234] Add GUI to Base Docker images & misc
Browse files Browse the repository at this point in the history
- Add GUI to base docker images (Ubuntu + Debian). This is done via an
  intermediate docker stage that creates the "plugins" directory and
  which is copied in the final stage. Entrypoint replaced to be able to
  start the GUI on port 9080 as well as run YottaDB.
- Fix build/run comments to be accruate, as the older ones were out of
  date (latest -> latest-master, remove UTF-8 [it's already default],
  add port option for GUI).
- Remove readline libraries: While I would like for readline to be
  available, we need a lot more packages to be installed in order for
  the unversioned .so to be available; but this image is supposed to be
  as small as possible. So, never mind.
- Fix libcurl packages in main Dockerfile. It was done incorrectly in
  commit f92ef46 (it added the libcurl
  for the YottaDB build stage, where it is not actually used--it should
  be added in two places: a dev library for the GUI build stage, and a
  runtime library for the runtime stage).

Image size:
- Ubuntu: was 220 MB -> now 285 MB
- Rocky: was 521 MB -> now 636 MB

README updated.
  • Loading branch information
shabiel committed Jun 27, 2024
1 parent e326c4e commit b8292d2
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 15 deletions.
47 changes: 41 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# Simple build/running directions are below:
#
# Build:
# $ docker build -t yottadb/yottadb:latest .
# $ docker build -t yottadb/yottadb:latest-master .
#
# Use with data persistence:
# $ docker run --rm -e ydb_chset=utf-8 -v `pwd`/ydb-data:/data -ti yottadb/yottadb:latest
# $ docker run -p 9080-9081:9080-9081 --rm -v `pwd`/ydb-data:/data -ti yottadb/yottadb:latest-master

ARG OS_VSN=22.04

Expand All @@ -36,7 +36,6 @@ RUN apt-get update && \
tcsh \
gawk \
libconfig-dev \
libcurl4-openssl-dev \
libelf-dev \
libicu-dev \
libncurses-dev \
Expand Down Expand Up @@ -84,11 +83,43 @@ RUN mkdir -p /tmp/yottadb-build \
&& make -j $(nproc) \
&& make install

# Stage 2: YottaDB release image
# Stage 2: YottaDB GUI install
FROM ubuntu:${OS_VSN} as ydb-gui

ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,target=/tmp/staging \
# This is a strange step: The mount volume is readonly; and we actually write to it in ydbinstall
# So we need to copy the mount contents to a seperate folder
cp -R /tmp/staging /tmp/ydb-release && \
# Add the CMake build_os_release file which is not part of the install directory
# Needed to allow us to build Ubuntu on AARCH64 for Docker Hub, but it's not officially supported
cp /etc/os-release /tmp/build_os_release && \
apt-get update && \
apt-get install -y --no-install-recommends \
file \
binutils \
libelf-dev \
libicu70 \
wget \
netbase \
readline-common \
cmake \
make \
binutils \
git \
pkg-config \
libcurl4-openssl-dev \
ca-certificates \
gcc \
&& \
/tmp/ydb-release/ydbinstall --utf8 --installdir /opt/yottadb/current --gui

# Stage 3: YottaDB release image
FROM ubuntu:${OS_VSN} as ydb-release

ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,target=/tmp/staging \
--mount=type=bind,from=ydb-gui,source=/opt/yottadb/current/plugin/,target=/tmp/plugin \
# This is a strange step: The mount volume is readonly; and we actually write to it in ydbinstall
# So we need to copy the mount contents to a seperate folder
cp -R /tmp/staging /tmp/ydb-release && \
Expand All @@ -104,17 +135,21 @@ RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,targe
nano \
wget \
netbase \
readline-common \
libcurl4 \
nodejs \
&& \
/tmp/ydb-release/ydbinstall --utf8 --installdir /opt/yottadb/current && \
cp -R /tmp/plugin /opt/yottadb/current/ && \
apt-get remove -y wget && \
apt-get autoclean -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/ydb-release

WORKDIR /data
EXPOSE 9080 9081
COPY ci/docker-scripts/docker-main-startup.sh /docker-main-startup.sh
ENV gtmdir=/data \
LC_ALL=C.UTF-8 \
EDITOR=/usr/bin/nano
ENTRYPOINT ["/opt/yottadb/current/ydb"]
ENTRYPOINT ["/docker-main-startup.sh"]
46 changes: 41 additions & 5 deletions Dockerfile-rocky
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# $ docker build -t yottadb/yottadb-rocky:latest-master -f Dockerfile-rocky .
#
# Use with data persistence:
# $ docker run --rm -v `pwd`/ydb-data:/data -ti yottadb/yottadb:latest
# $ docker run --rm -p 9080-9081:9080-9081 -v `pwd`/ydb-data:/data -ti yottadb/yottadb-rocky:latest-master

# Stage 1: YottaDB build image
FROM rockylinux:8.8 as ydb-release-builder
Expand Down Expand Up @@ -76,10 +76,44 @@ RUN mkdir -p /tmp/yottadb-build \
&& make -j `grep -c ^processor /proc/cpuinfo` \
&& make install

# Stage 2: YottaDB release image
# Stage 2: YottaDB GUI install
FROM rockylinux:8.8 as ydb-gui

RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,target=/tmp/staging \
# This is a strange step: The mount volume is readonly; and we actually write to it in ydbinstall
# So we need to copy the mount contents to a seaprate folder
cp -R /tmp/staging /tmp/ydb-release && \
yum update -y && \
yum install -y \
file \
binutils \
findutils \
elfutils-libelf \
libicu \
wget \
procps-ng \
nano \
gzip \
cmake \
git \
pkg-config \
make \
gcc \
libcurl-devel \
&& \
# Add the CMake build_os_release file which is not part of the install
# directory Needed to allow us to build Rocky Linux on AARCH64 for Docker
# Hub, but it's not officially supported. We do this AFTER yum update, since
# it can change the minor version and cause /etc/os-release and
# /tmp/build_os_release to be different and result in ydbinstall failing.
cp /etc/os-release /tmp/build_os_release && \
/tmp/ydb-release/ydbinstall --utf8 --installdir /opt/yottadb/current --gui

# Stage 3: YottaDB release image
FROM rockylinux:8.8 as ydb-release

RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,target=/tmp/staging \
--mount=type=bind,from=ydb-gui,source=/opt/yottadb/current/plugin/,target=/tmp/plugin \
# This is a strange step: The mount volume is readonly; and we actually write to it in ydbinstall
# So we need to copy the mount contents to a seaprate folder
cp -R /tmp/staging /tmp/ydb-release && \
Expand All @@ -94,7 +128,7 @@ RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,targe
procps-ng \
nano \
gzip \
readline \
nodejs \
&& \
# Add the CMake build_os_release file which is not part of the install
# directory Needed to allow us to build Rocky Linux on AARCH64 for Docker
Expand All @@ -103,14 +137,16 @@ RUN --mount=type=bind,from=ydb-release-builder,source=/tmp/yottadb-release,targe
# /tmp/build_os_release to be different and result in ydbinstall failing.
cp /etc/os-release /tmp/build_os_release && \
/tmp/ydb-release/ydbinstall --utf8 --installdir /opt/yottadb/current && \
cp -R /tmp/plugin /opt/yottadb/current/ && \
yum remove -y wget && \
yum clean all && \
rm -rf /var/cache/yum && \
rm -rf /tmp/ydb-release

WORKDIR /data
EXPOSE 9080 9081
COPY ci/docker-scripts/docker-main-startup.sh /docker-main-startup.sh
ENV gtmdir=/data \
LC_ALL=C.UTF-8 \
EDITOR=/usr/bin/nano

ENTRYPOINT ["/opt/yottadb/current/ydb"]
ENTRYPOINT ["/docker-main-startup.sh"]
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ NOTE: You must have at least docker 17.05 as [multi-stage](https://docs.docker.c

### Image information

The docker image is built using the generic ```ydb``` script that gives the user some sane defaults to begin exploring YottaDB. This isn't meant for production usage.
The docker image is built using the generic `ydb_env_set` script that gives the user some sane defaults to begin exploring YottaDB. This isn't meant for production usage.
The commands below assume that you want to remove the docker container after running the command, which means that if you don't mount a volume that contains your database and routines they will be lost. If you want the container to persist remove the ```--rm``` parameter from the ```docker``` command.

Expand All @@ -156,25 +156,27 @@ Volumes are also supported by mounting to the ```/data``` directory. If you want

This creates a ydb-data directory in your current working directory. This can be deleted after the container is shutdown/removed if you want to remove all data created in the YottaDB container (such as your database and routines).

The [YottaDB GUI](https://gitlab.com/YottaDB/UI/YDBGUI) is available on port 9080; statistics for the GUI is running on port 9081.

### Pre-built images

Pre-built images are available on [docker hub](https://hub.docker.com/r/yottadb/)

### Running a Pre-built image

```
docker run --rm -it download.yottadb.com/yottadb/yottadb # you can add a specific version after a ":" if desired
docker run --rm -it -p 9080-9081:9080-9081 download.yottadb.com/yottadb/yottadb # you can add a specific version after a ":" if desired
```

### Build Steps

1) Build the image
```
docker build -t yottadb/yottadb:latest .
docker build -t yottadb/yottadb:latest-master .
```
2) Run the created image
```
docker run --rm -it yottadb/yottadb:latest
docker run --rm -it -p 9080-9081:9080-9081 yottadb/yottadb:latest-master
```

## FAQ
Expand Down
16 changes: 16 additions & 0 deletions ci/docker-scripts/docker-main-startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#################################################################
# #
# Copyright (c) 2024 YottaDB LLC and/or its subsidiaries. #
# All rights reserved. #
# #
# This source code contains the intellectual property #
# of its copyright holder(s), and is made available #
# under a license. If you do not know the terms of #
# the license, please stop and do not read further. #
# #
#################################################################
mkdir -p /data/logs
. /opt/yottadb/current/ydb_env_set
yottadb -run %ydbgui --readwrite --port 9080 >>/data/logs/%ydbgui.log &
exec /opt/yottadb/current/yottadb -direct

0 comments on commit b8292d2

Please sign in to comment.