Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
rrozek committed Mar 20, 2024
1 parent ce114e3 commit 73065fe
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions Dockerfile
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"]

0 comments on commit 73065fe

Please sign in to comment.