29 lines
556 B
Docker
29 lines
556 B
Docker
FROM node:22-alpine
|
|
|
|
# Set the working directory
|
|
WORKDIR /usr/app
|
|
|
|
# Copy package.json and package-lock.json
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Change ownership to the non-root user
|
|
RUN chown -R node:node /usr/app
|
|
|
|
# Copy the rest of the application code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Expose the application port
|
|
EXPOSE 3001
|
|
|
|
# Run container as non-root (unprivileged) user
|
|
# The "node" user is provided in the Node.js Alpine base image
|
|
USER node
|
|
|
|
# Command to run the application
|
|
CMD ["npm", "start"] |