2024-07-28 11:28:08 -06:00
|
|
|
# Stage 1: Build the Angular application
|
|
|
|
FROM node:alpine AS builder
|
2024-07-28 03:04:23 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /
|
2024-07-28 03:04:23 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Copy package.json and package-lock.json
|
2024-07-28 03:04:23 -06:00
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Install dependencies
|
2024-07-28 03:04:23 -06:00
|
|
|
RUN npm install
|
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Copy the rest of the application code
|
|
|
|
COPY . .
|
|
|
|
COPY dist dist
|
2024-07-28 03:04:23 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Build the application for production
|
|
|
|
# RUN npm run build:prod
|
2024-07-28 03:04:23 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Stage 2: Serve the application with Nginx
|
2024-07-28 08:17:22 -06:00
|
|
|
FROM nginx:latest
|
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
RUN mkdir /app
|
2024-07-28 08:17:22 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# 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
|
2024-07-28 08:17:22 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Copy the custom Nginx configuration file
|
|
|
|
COPY config/default.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# COPY config/default.conf test.txt
|
2024-07-28 08:17:22 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Expose port 80
|
|
|
|
EXPOSE 80
|
2024-07-28 03:04:23 -06:00
|
|
|
|
2024-07-28 11:28:08 -06:00
|
|
|
# Start Nginx
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|