-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,13 @@ | ||
# First stage: Build the application | ||
FROM node:18-slim as builder | ||
FROM node:18-alpine | ||
RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app | ||
WORKDIR /usr/src/node-app | ||
USER node | ||
|
||
WORKDIR /app | ||
COPY --chown=node:node package*.json ./ | ||
|
||
# Copy package.json and package-lock.json files first | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
COPY . . | ||
|
||
# Build application | ||
COPY --chown=node:node . . | ||
RUN npm run build | ||
|
||
# Second stage: Setup the production image | ||
FROM node:16-alpine | ||
|
||
WORKDIR /app | ||
|
||
# Copy built assets from the builder stage to production image | ||
COPY --from=builder /app/dist ./dist | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/node_modules ./node_modules | ||
|
||
# Run the server in production mode | ||
CMD npm run server:prod | ||
|
||
EXPOSE 8080 | ||
CMD ["npm", "run", "server:prod"] | ||
|