Created
May 23, 2024 21:28
-
-
Save ndamulelonemakh/b8cc570338363d11fc7bf7b68e2686e9 to your computer and use it in GitHub Desktop.
Sample docker file for running angular 17+ with ssr support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:lts-alpine as build | |
WORKDIR /app | |
COPY package*.json ./ | |
# Install dependencies | |
RUN npm ci --force | |
COPY . . | |
# Set environment for Angular CLI | |
ARG configuration=production | |
RUN npm run build:ssr --configuration $configuration | |
FROM node:lts-alpine as runtime | |
# Set working directory | |
WORKDIR /app | |
# Copy the built Angular app from the build stage | |
COPY --from=build /app/dist/your-app-name/browser /app/browser | |
COPY --from=build /app/dist/your-app-name/server /app/server | |
# Expose the port your Angular app will run on (default is 4000 for Angular Universal) | |
EXPOSE 4000 | |
# Set environment for Angular Universal | |
ENV NODE_ENV=production | |
# Start the Angular Universal server | |
CMD ["node", "server/main.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment