Skip to content

Commit

Permalink
DBZ-7447 Add Debezium UI container image for production use based on …
Browse files Browse the repository at this point in the history
  • Loading branch information
rk3rn3r authored and jpechane committed Feb 12, 2024
1 parent 35e1909 commit 14b92a5
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 16 deletions.
28 changes: 16 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 2 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// config.js
module.exports = {
KAFKA_CONNECT_CLUSTERS: process.env.KAFKA_CONNECT_CLUSTERS || 'http://localhost:8084/,http://localhost:8085/',
};

KAFKA_CONNECT_CLUSTERS: process.env.KAFKA_CONNECT_CLUSTERS || 'http://localhost:8083',
};
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"KAFKA_CONNECT_CLUSTERS": "http://localhost:8083"
}
33 changes: 33 additions & 0 deletions deployment/image/create-dbzui-config.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 14b92a5

Please sign in to comment.