You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2021/09/02 11:43:43 UTC

[cassandra-website] 04/07: CASSANDRA-16066: Add website UI development tooling

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-website.git

commit 32e8c8cf27ba879c9368eb5236186f36d5d65f38
Author: Anthony Grasso <an...@thelastpickle.com>
AuthorDate: Thu Apr 15 16:00:00 2021 +1000

    CASSANDRA-16066: Add website UI development tooling
    
    This commit adds a Docker container that wraps the Gulp commands used for
    developing the Antora site UI components.
    
    patch by Anthony Grasso; reviewed by Mick Semb Wever, Lorina Poland, Melissa Logan, Paul Au for CASSANDRA-16066
---
 site-ui/Dockerfile           | 57 ++++++++++++++++++++++++++++++++++++++++++++
 site-ui/docker-entrypoint.sh | 23 ++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/site-ui/Dockerfile b/site-ui/Dockerfile
new file mode 100644
index 0000000..bda8694
--- /dev/null
+++ b/site-ui/Dockerfile
@@ -0,0 +1,57 @@
+FROM ubuntu:18.04
+# Set up non-root user, 'build', with default uid:gid
+# This allows passing --build-arg to use localhost username, and uid:gid:
+#   $ docker build \
+#       -t cassandra-website-ui:latest \
+#       --build-arg BUILD_USER_ARG=$(whoami) \
+#       --build-arg UID_ARG=$(id -u) \
+#       --build-arg GID_ARG=$(id -g) \
+#       .
+#
+# Other container parameters can be overridden at build time as well:
+#  - NODE_VERSION_ARG:              Version of node to use.
+ARG BUILD_USER_ARG="build"
+ARG UID_ARG=1000
+ARG GID_ARG=1000
+ARG NODE_VERSION_ARG="v12.16.2"
+
+ENV BUILD_USER=${BUILD_USER_ARG}
+
+RUN echo "Building with arguments:" \
+    && echo " - BUILD_USER_ARG=${BUILD_USER_ARG}" \
+    && echo " - UID_ARG=${UID_ARG}" \
+    && echo " - GID_ARG=${GID_ARG}" \
+    && echo " - NODE_VERSION_ARG=${NODE_VERSION_ARG}"
+
+RUN echo "Setting up user '${BUILD_USER}'"
+RUN groupadd --gid ${GID_ARG} --non-unique ${BUILD_USER}
+RUN useradd --create-home --shell /bin/bash \
+    --uid ${UID_ARG} --gid ${GID_ARG} --non-unique ${BUILD_USER}
+
+RUN apt-get update && \
+    apt-get install -y \
+        wget \
+        git \
+        vim
+
+ENV NODE_PACKAGE="node-${NODE_VERSION_ARG}-linux-x64.tar.gz"
+RUN wget https://nodejs.org/download/release/${NODE_VERSION_ARG}/${NODE_PACKAGE} && \
+    tar -C /usr/local --strip-components 1 -xzf ${NODE_PACKAGE} && \
+    rm ${NODE_PACKAGE}
+
+RUN npm install -g gulp-cli
+
+ENV BUILD_DIR="/home/${BUILD_USER}"
+WORKDIR ${BUILD_DIR}
+RUN mkdir -p ${BUILD_DIR}/site-ui && \
+    chmod -R a+rw ${BUILD_DIR} && \
+    chown -R ${BUILD_USER}:${BUILD_USER} ${BUILD_DIR}
+
+EXPOSE 5252/tcp
+
+# Run as build user from here
+USER ${BUILD_USER}
+WORKDIR ${BUILD_DIR}/site-ui
+COPY docker-entrypoint.sh /usr/local/bin/
+ENTRYPOINT ["docker-entrypoint.sh"]
+CMD ["--tasks", "--depth", "1"]
\ No newline at end of file
diff --git a/site-ui/docker-entrypoint.sh b/site-ui/docker-entrypoint.sh
new file mode 100755
index 0000000..d2c6e1a
--- /dev/null
+++ b/site-ui/docker-entrypoint.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Abort script if a command fails
+set -e
+
+GREEN='\033[1;32m'
+YELLOW='\033[0;33m'
+NC='\033[0m' # No Color
+
+if [ ! -d "node_modules" ]
+then
+  echo
+  echo -e "${YELLOW}The node_modules directory is missing and we need it to render the UI.${NC}"
+  echo -e "${YELLOW}I'll run a once off install of the required modules. This will take a few minutes to complete.${NC}"
+  echo
+
+  # Install node modules
+  npm install
+
+  echo -e -n "${GREEN}Install complete!${NC}"
+fi
+
+exec gulp "$@"
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org