From eff4cc7c21b4a7d917b8c32b326c66bb6ab5dcb6 Mon Sep 17 00:00:00 2001 From: aliyaghini <62905408+aliyaghini@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:45:05 +0330 Subject: [PATCH] feat(Dockerfile): first structure of Dockerfile added (#2) * feat(Dockerfile): create multi-stage dockerfile to test and develop * feat(Dockerfile): build and nginx stages added to dockerfile --- Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f2e87e4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +FROM node:20 AS base + +FROM base as test + +WORKDIR /app + +COPY package*.json ./ + +RUN npm ci && npm install -g @angular/cli@18.1.4 + +RUN apt-get update && apt-get install -y \ + wget \ + gnupg2 \ + && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ + && apt-get update \ + && apt-get install -y google-chrome-stable \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ENV CHROME_BIN="/usr/bin/google-chrome" + +# TODO: Use cache + +COPY . . + +RUN npm test --watch=false --browsers=ChromeHeadlessNoSandbox + + +FROM base as build + +WORKDIR /app + +COPY . . + +RUN npm ci + +RUN npm run build + + +FROM nginx:latest + +COPY nginx.conf /etc/nginx/nginx.conf + +COPY --from=build /app/dist/nginx-example-app /usr/share/nginx/html + +