From 55027ec809fcc7426e0b24eda8d656d3071d8d4d Mon Sep 17 00:00:00 2001 From: pawan-59 Date: Thu, 16 Jan 2025 14:06:08 +0530 Subject: [PATCH 1/2] uodated Dockerfile to remove extra layers --- Dockerfile | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e2df69eab..faae768264 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,38 @@ FROM node:20-alpine AS builder -RUN apk add --no-cache git - WORKDIR /app -COPY package.json . -COPY yarn.lock . - -RUN yarn install --network-timeout 600000 -COPY src/ src -COPY nginx.conf . -COPY tsconfig.json . -COPY vite.config.mts . -COPY . . +COPY package.json yarn.lock . -RUN echo `git rev-parse --short HEAD` > health.html +RUN apk add --no-cache git && \ + yarn install --network-timeout 600000 -RUN echo "SENTRY_RELEASE_VERSION=dashboard@$(git rev-parse --short HEAD)" >> .env +COPY . . -RUN yarn build +RUN echo `git rev-parse --short HEAD` > health.html && \ + echo "SENTRY_RELEASE_VERSION=dashboard@$(git rev-parse --short HEAD)" >> .env && \ + yarn build FROM nginx:stable RUN useradd -ms /bin/bash devtron + COPY --from=builder /app/dist/ /usr/share/nginx/html + COPY ./nginx.conf /etc/nginx/nginx.conf + COPY ./nginx-default.conf /etc/nginx/conf.d/default.conf + WORKDIR /usr/share/nginx/html -COPY --from=builder /app/./env.sh . + +COPY --from=builder --chmod=+x /app/./env.sh . + COPY --from=builder /app/.env . + COPY --from=builder /app/health.html . RUN chown -R devtron:devtron /usr/share/nginx/html # Make our shell script executable -RUN chmod +x env.sh USER devtron + CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""] From b70ce9f261b4e9f5f9eddf240fc0625b826adcfd Mon Sep 17 00:00:00 2001 From: pawan-59 Date: Thu, 16 Jan 2025 14:22:28 +0530 Subject: [PATCH 2/2] updated Dockerfile --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index faae768264..95ec0bd4ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ COPY ./nginx-default.conf /etc/nginx/conf.d/default.conf WORKDIR /usr/share/nginx/html -COPY --from=builder --chmod=+x /app/./env.sh . +COPY --from=builder /app/./env.sh . COPY --from=builder /app/.env . @@ -33,6 +33,8 @@ COPY --from=builder /app/health.html . RUN chown -R devtron:devtron /usr/share/nginx/html # Make our shell script executable +RUN chmod +x env.sh + USER devtron CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]