Skip to content

Instantly share code, notes, and snippets.

@alisafariir
Created June 29, 2024 07:10
Show Gist options
  • Save alisafariir/44c8a1de8c91febb9ac35d32208d82d2 to your computer and use it in GitHub Desktop.
Save alisafariir/44c8a1de8c91febb9ac35d32208d82d2 to your computer and use it in GitHub Desktop.
Angular SSR Dockerfile
# Stage 1: Build the Angular application
FROM node:22.3.0-alpine AS build
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm i
# Copy the entire application source code
COPY . .
# Build the Angular SSR application
RUN npm run build:ssr
# Stage 2: Create the final production image
FROM node:22.3.0-alpine
WORKDIR /usr/src/app
# Copy the built Angular SSR files from the previous stage
COPY --from=build /usr/src/app/dist ./dist
# Install only production dependencies
COPY package*.json ./
RUN npm i
# Start the SSR server
CMD ["npm", "run", "serve:ssr"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment