From 26558379be72029f3817fb672524ddc610efbd89 Mon Sep 17 00:00:00 2001 From: Mathew Guest Date: Sun, 28 Jul 2024 11:28:08 -0600 Subject: [PATCH] build: working podman deploy and build Dockerfile --- Dockerfile | 38 ++++++++++++++++++++++++-------------- config/default.conf | 11 ++++++----- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index f7c9bdc..8aacdd7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,37 @@ -FROM node:alpine As builder +# Stage 1: Build the Angular application +FROM node:alpine AS builder -WORKDIR /app +# Set the working directory +WORKDIR / +# Copy package.json and package-lock.json COPY package.json package-lock.json ./ +# Install dependencies RUN npm install -# COPY . . +# Copy the rest of the application code +COPY . . +COPY dist dist -RUN npm run build --prod +# Build the application for production +# RUN npm run build:prod +# Stage 2: Serve the application with Nginx FROM nginx:latest -COPY dist/angular-starter /usr/share/nginx/html +RUN mkdir /app + +# Copy the built application from the builder stage to the Nginx html directory +COPY --from=builder dist/angular-starter /usr/share/nginx/html +COPY --from=builder dist/angular-starter /app + +# Copy the custom Nginx configuration file COPY config/default.conf /etc/nginx/conf.d/default.conf -# COPY --from=builder /usr/src/app/dist/angular-starter/ /usr/share/nginx/html - - - - - - - - +# COPY config/default.conf test.txt +# Expose port 80 +EXPOSE 80 +# Start Nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/config/default.conf b/config/default.conf index a5a48e4..2cac6b9 100644 --- a/config/default.conf +++ b/config/default.conf @@ -3,13 +3,14 @@ server { server_name localhost; location / { - try_files $uri $uri/ /index.html - root /usr/share/nginx/html; - index index.html index.htm + try_files $uri $uri/ /index.html; + root /app; + index index.html; + } - error_page 500 502 503 504 /50x.html - location = { + error_page 500 502 503 504 /50x.html; + location = /50x.html { root /usr/share/nginx/html; }