diff --git a/Dockerfile b/Dockerfile index 8d2f51b9..e007d20a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,25 @@ #### -# This Dockerfile is used in order to build a container with Debezium UI. +# This Dockerfile is used to build a production container image for Debezium UI. ### -# Build UI -FROM registry.access.redhat.com/ubi9/nodejs-18 AS build +FROM registry.access.redhat.com/ubi9/nodejs-20:1-24 as builder + WORKDIR /app COPY --chown=1001 package*.json ./ + RUN npm install + COPY --chown=1001 . . -RUN npm run build -# Final image with only build artifacts -FROM node:18-slim -WORKDIR /app -RUN npm install express -COPY --from=build /app/dist/serve.js /app/dist/config.js ./ -COPY --from=build /app/dist ./dist -EXPOSE 3000 ENV NODE_ENV=production + +# Build the React application +RUN npm run build + + +FROM nginx:1.25.3-alpine + ENV KAFKA_CONNECT_CLUSTERS=http://localhost:8083/ -CMD ["node", "serve"] + +COPY --from=builder /app/dist /usr/share/nginx/html +COPY config.json /app/config.json +COPY deployment/image/create-dbzui-config.sh /docker-entrypoint.d/ diff --git a/config.js b/config.js index 358bbb1b..3da2ded0 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,3 @@ -// config.js module.exports = { - KAFKA_CONNECT_CLUSTERS: process.env.KAFKA_CONNECT_CLUSTERS || 'http://localhost:8084/,http://localhost:8085/', - }; - \ No newline at end of file + KAFKA_CONNECT_CLUSTERS: process.env.KAFKA_CONNECT_CLUSTERS || 'http://localhost:8083', +}; diff --git a/config.json b/config.json new file mode 100644 index 00000000..1206b8e0 --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{ + "KAFKA_CONNECT_CLUSTERS": "http://localhost:8083" +} diff --git a/deployment/image/create-dbzui-config.sh b/deployment/image/create-dbzui-config.sh new file mode 100755 index 00000000..3688156c --- /dev/null +++ b/deployment/image/create-dbzui-config.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# vim:sw=4:ts=4:et + +set -e + +entrypoint_log() { + if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then + echo "$@" + fi +} + +ME=$(basename "$0") +DBZUI_CONFIG_TEMPLATE="/app/config.json" +DBZUI_CONFIG_FILE="/usr/share/nginx/html/config" + +if [ ! -f "${DBZUI_CONFIG_TEMPLATE}" ]; then + echo "${ME}: ERROR: ${DBZUI_CONFIG_TEMPLATE} is not a file or does not exist" + exit 1 +fi + +# check if the file can be modified, e.g. not on a r/o filesystem +cp "${DBZUI_CONFIG_TEMPLATE}" "${DBZUI_CONFIG_FILE}" >/dev/null 2>&1 || { echo "$ME: ERROR: can not modify ${DBZUI_CONFIG_FILE} (read-only file system?)"; exit 1; } + +if [ "${KAFKA_CONNECT_CLUSTERS}" == "http://localhost:8083" ] ; then + ## nothing to do, keep the default config + exit 0 +fi + +# escaping slashes +KAFKA_CONNECT_CLUSTERS_ESCAPED=`echo ${KAFKA_CONNECT_CLUSTERS} | sed -e 's;\/;\\\/;g'` +sed -i "s/http:\/\/localhost:8083/${KAFKA_CONNECT_CLUSTERS_ESCAPED}/g" "${DBZUI_CONFIG_FILE}" + +exit 0 diff --git a/dev.Dockerfile b/dev.Dockerfile new file mode 100644 index 00000000..3c931822 --- /dev/null +++ b/dev.Dockerfile @@ -0,0 +1,20 @@ +#### +# This Dockerfile is used in order to build a container with Debezium UI for development. +### +FROM registry.access.redhat.com/ubi9/nodejs-18 + +WORKDIR /app + +COPY --chown=1001 package*.json ./ + +RUN npm install + +COPY --chown=1001 . . + +ENV NODE_ENV=production +ENV KAFKA_CONNECT_CLUSTERS=http://localhost:8083/ + +RUN npm run build + +EXPOSE 3000 +CMD ["npm", "run", "start:dev"]