From 35e1909c1d731b7cf7b0f302c0527d8902d8c614 Mon Sep 17 00:00:00 2001 From: Indra Date: Fri, 9 Feb 2024 14:12:25 +0530 Subject: [PATCH] DBZ-7447: Docker image update (#851) Co-authored-by: Indra Shukla --- Dockerfile | 33 +++++++++------------------------ webpack.common.js | 3 +++ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 24187cde..8d2f51b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,21 @@ #### # This Dockerfile is used in order to build a container with Debezium UI. ### - -FROM registry.access.redhat.com/ubi9/nodejs-18 - -# Set the working directory inside the container +# Build UI +FROM registry.access.redhat.com/ubi9/nodejs-18 AS build WORKDIR /app - -# Copy package.json and package-lock.json (or yarn.lock) to the working directory COPY --chown=1001 package*.json ./ - -# Install dependencies RUN npm install - -# Copy the rest of the application code to the working directory 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 - -# Set the environment variable NODE_ENV to "production" ENV NODE_ENV=production - -# Set the environment variable KAFKA_CONNECT_CLUSTERS ENV KAFKA_CONNECT_CLUSTERS=http://localhost:8083/ - -# Build the React application -RUN npm run build - -# Install a lightweight web server -# RUN npm install -g serve - -# Set the command to start the web server and serve the built application CMD ["node", "serve"] - -# CMD ["npm", "run", "start:dev"] diff --git a/webpack.common.js b/webpack.common.js index af08b072..a09ac1b7 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -142,6 +142,9 @@ module.exports = (env) => { new CopyPlugin({ patterns: [{ from: './config.js', to: './' }], }), + new CopyPlugin({ + patterns: [{ from: './serve.js', to: './' }], + }), ], resolve: { extensions: ['.js', '.ts', '.tsx', '.jsx'],