initial commit
This commit is contained in:
29
Dockerfile
Normal file
29
Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# Use Node.js LTS as the base image
|
||||
FROM node:20-slim
|
||||
|
||||
# Create app directory and set ownership
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install production dependencies only
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Create a non-root user and switch to it
|
||||
RUN groupadd -r nodejs && useradd -r -g nodejs nodejs \
|
||||
&& chown -R nodejs:nodejs /app
|
||||
|
||||
USER nodejs
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 3000
|
||||
|
||||
# Set NODE_ENV to production
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Command to run the application
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user