FROM node:20-alpine | |
# Create app directory | |
WORKDIR /app | |
RUN sudo npm install -g --unsafe-perm=true --allow-root | |
# Install app dependencies | |
COPY package*.json ./ | |
RUN npm install | |
# Bundle app source | |
COPY . . | |
# Create a non-root user and switch to it | |
RUN addgroup -g 1001 -S nodejs | |
RUN adduser -S nestjs -u 1001 | |
RUN chown -R nestjs:nodejs /app | |
USER nestjs | |
# Expose the port the app runs on | |
EXPOSE 7860 | |
# Command to run the application | |
CMD ["npm", "run", "start:dev"] | |