From d2ac47173ba7e2405f629f82c9a7936d9a5ab71c Mon Sep 17 00:00:00 2001 From: Mehmet Can Ay Date: Fri, 19 Apr 2024 20:29:15 +0200 Subject: [PATCH] refactor: divide into two stages --- frontend/Dockerfile | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5b860a7..3ca15eb 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,14 +1,27 @@ +# FIRST STAGE # Define the base image -FROM node:alpine +FROM node:20.12.2 as build -# Create a folder and copy the folder structure from local +# Create a folder, and copy package.json and package-lock.json to it WORKDIR /app -COPY . /app +COPY package*.json ./ # Install dependencies -RUN npm install -g @angular/cli RUN npm install -EXPOSE 4200 +# Install Angular +RUN npm install -g @angular/cli + +# Copy all the files in the current directory to the container +COPY . ./ + +# Build the Angular application +RUN ng build --configuration=production + +# SECOND STAGE +# Define the base image +FROM nginx:latest + +COPY --from=build app/dist/aftas-angular /usr/share/nginx/html -CMD ["ng", "serve", "--host", "0.0.0.0", "--port", "4200"] +EXPOSE 80