Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
njts authored Jan 23, 2023
1 parent 6f63355 commit aa39499
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
# Use the official Node.js Alpine image as the base image
FROM node AS build-stage

# Create a limited user
RUN adduser -D myuser
USER myuser
FROM node:alpine

# Set the working directory in the container
WORKDIR /app

# Copy the package.json and package-lock.json files from the backend directory to the container
COPY package*.json ./

# Install the production dependencies in the container and verify the integrity of the installed npm packages
RUN npm ci --only=production --verify-only
RUN npm ci --only=production

# Copy the rest of the app's files from the backend directory to the container
COPY . .

# Build the app
RUN npm run build

# Start a new stage for the final image
FROM node:alpine

# Create a limited user
RUN adduser -D myuser
USER myuser

# Set the working directory in the container
WORKDIR /app

# Copy the built app files from the previous stage
COPY --from=build-stage /app/dist ./dist

# Make the filesystem read-only
RUN chmod -R 555 /app

# Expose the port that the app runs on
EXPOSE 3000

# Add the start command
Expand Down

0 comments on commit aa39499

Please sign in to comment.