From fea1572d7b13f0e3b488e8efccabf69093b635e8 Mon Sep 17 00:00:00 2001 From: AbhayMishra Date: Sun, 5 Jan 2025 15:18:34 +0530 Subject: [PATCH 1/2] Updated and optimised Dockerfile and modified dockerignore --- .dockerignore | 1 - Dockerfile | 29 +++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index fd00eaa96..053aea7c1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,7 +6,6 @@ **/.classpath **/.dockerignore -**/.env **/.git **/.gitignore **/.project diff --git a/Dockerfile b/Dockerfile index ed9ac7892..0415e2d4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,37 @@ FROM node:20-alpine WORKDIR /app -COPY package*.json ./ +RUN apk add --no-cache git curl bash && \ + rm -f /usr/local/bin/yarn /usr/local/bin/yarnpkg && \ + curl -o /tmp/yarn-4.4.0.tar.gz -L https://github.com/yarnpkg/berry/archive/refs/tags/@yarnpkg/cli/4.4.0.tar.gz && \ + mkdir -p /opt/yarn && \ + tar -xzf /tmp/yarn-4.4.0.tar.gz -C /opt/yarn --strip-components=1 && \ + ln -s /opt/yarn/packages/yarnpkg-cli/bin/yarn.js /usr/local/bin/yarn && \ + ln -s /opt/yarn/packages/yarnpkg-cli/bin/yarn.js /usr/local/bin/yarnpkg && \ + rm -rf /tmp/yarn-4.4.0.tar.gz + +COPY . . RUN apk add --update git && \ git init && \ git submodule init && \ git submodule update && \ - yarn + yarn install && \ + yarn cache clean && \ + rm -rf .git && \ + rm -rf /root/.cache && \ + rm -rf /root/.npm && \ + rm -rf /root/.yarn && \ + rm -rf /tmp/* && \ + apk del git curl && \ + rm -rf /var/cache/apk/* -COPY . . +RUN if [ ! -f .env ]; then \ + cp .env.example .env && rm -rf .env.example; \ + else \ + rm -rf .env.example; \ + fi EXPOSE 3000 -CMD yarn dev +CMD ["yarn", "dev"] From 56bfe569e5024b0166a9b81fa710b22aed12d7c4 Mon Sep 17 00:00:00 2001 From: AbhayMishra Date: Sun, 5 Jan 2025 19:06:25 +0530 Subject: [PATCH 2/2] removed env logic from dockerfile and added .env in .dockerignore --- .dockerignore | 1 + Dockerfile | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 053aea7c1..fd00eaa96 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,6 +6,7 @@ **/.classpath **/.dockerignore +**/.env **/.git **/.gitignore **/.project diff --git a/Dockerfile b/Dockerfile index 0415e2d4d..c52af9680 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,12 +27,6 @@ RUN apk add --update git && \ apk del git curl && \ rm -rf /var/cache/apk/* -RUN if [ ! -f .env ]; then \ - cp .env.example .env && rm -rf .env.example; \ - else \ - rm -rf .env.example; \ - fi - EXPOSE 3000 CMD ["yarn", "dev"]