-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-8606: Add Dockerfile for stage image with build from the source r…
…espo
- Loading branch information
Showing
2 changed files
with
75 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#### | ||
# This Dockerfile is used in order to build a container with Debezium platform UI. | ||
### | ||
ARG VERSION=main | ||
|
||
# Clone the repository | ||
FROM registry.access.redhat.com/ubi9/ubi-minimal AS cloner | ||
ARG VERSION | ||
WORKDIR /app | ||
RUN microdnf install -y git && \ | ||
git clone https://github.com/debezium/debezium-platform.git && \ | ||
cd debezium-platform && \ | ||
git checkout ${VERSION} && \ | ||
cd debezium-platform-stage | ||
|
||
# Build the application | ||
FROM registry.access.redhat.com/ubi9/nodejs-20 AS builder | ||
USER root | ||
RUN mkdir -p /app && chown 1001:1001 /app | ||
USER 1001 | ||
RUN npm install -g yarn | ||
|
||
WORKDIR /app | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/package.json /app/ | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/yarn.lock /app/ | ||
RUN yarn install | ||
|
||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage /app | ||
RUN yarn build | ||
|
||
# Final image | ||
FROM mirror.gcr.io/library/node:20-alpine | ||
RUN yarn global add serve | ||
|
||
WORKDIR /app | ||
COPY --from=builder /app/dist /app/dist | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/inject-env.sh /inject-env.sh | ||
RUN chmod +x /inject-env.sh | ||
|
||
LABEL maintainer="Debezium Community" \ | ||
description="Debezium Platform Stage UI" | ||
|
||
EXPOSE 3000 | ||
CMD ["/inject-env.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
#### | ||
# This Dockerfile is used in order to build a container with Debezium platform UI. | ||
### | ||
FROM registry.access.redhat.com/ubi9/nodejs-20 AS builder | ||
WORKDIR /build | ||
|
||
# Install package and extract necessary files | ||
RUN npm install -g serve && \ | ||
npm install @debezium/platform-stage@latest && \ | ||
mkdir -p /build/output && \ | ||
cp -r node_modules/@debezium/platform-stage/dist /build/output/ && \ | ||
cp node_modules/@debezium/platform-stage/dist/inject-env.sh /build/output/ | ||
ARG VERSION=main | ||
|
||
# Final image | ||
FROM mirror.gcr.io/library/node:20-alpine | ||
# Clone the repository | ||
FROM registry.access.redhat.com/ubi9/ubi-minimal AS cloner | ||
ARG VERSION | ||
WORKDIR /app | ||
RUN microdnf install -y git && \ | ||
git clone https://github.com/debezium/debezium-platform.git && \ | ||
cd debezium-platform && \ | ||
git checkout ${VERSION} && \ | ||
cd debezium-platform-stage | ||
|
||
# Build the application | ||
FROM registry.access.redhat.com/ubi9/nodejs-20 AS builder | ||
USER root | ||
RUN mkdir -p /app && chown 1001:1001 /app | ||
USER 1001 | ||
RUN npm install -g yarn | ||
|
||
RUN apk add --no-cache wget && \ | ||
npm install -g serve --production && \ | ||
addgroup -S appgroup && \ | ||
adduser -S appuser -G appgroup -u 1001 && \ | ||
chown -R appuser:appgroup /app | ||
WORKDIR /app | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/package.json /app/ | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/yarn.lock /app/ | ||
RUN yarn install | ||
|
||
# Copy only necessary files from builder | ||
COPY --from=builder --chown=appuser:appgroup /build/output/dist ./dist | ||
COPY --from=builder --chown=appuser:appgroup /build/output/inject-env.sh ./inject-env.sh | ||
RUN chmod +x /app/inject-env.sh | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage /app | ||
RUN yarn build | ||
|
||
USER appuser | ||
# Final image | ||
FROM mirror.gcr.io/library/node:20-alpine | ||
RUN yarn global add serve | ||
|
||
ENV NODE_ENV=production \ | ||
PORT=3000 \ | ||
PATH="/usr/local/bin:${PATH}" | ||
WORKDIR /app | ||
COPY --from=builder /app/dist /app/dist | ||
COPY --from=cloner /app/debezium-platform/debezium-platform-stage/inject-env.sh /inject-env.sh | ||
RUN chmod +x /inject-env.sh | ||
|
||
LABEL maintainer="Debezium Community" \ | ||
description="Debezium Platform Stage UI" \ | ||
org.opencontainers.image.source="https://github.com/debezium/debezium-platform" | ||
description="Debezium Platform Stage UI" | ||
|
||
EXPOSE 3000 | ||
CMD ["./inject-env.sh"] | ||
CMD ["/inject-env.sh"] |