.
This commit is contained in:
@@ -7,8 +7,11 @@ WORKDIR /app
|
||||
# Copy package.json and package-lock.json (if available)
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
# Install all dependencies (including dev dependencies)
|
||||
RUN npm install
|
||||
|
||||
# Install nodemon globally for development
|
||||
RUN npm install -g nodemon
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
@@ -16,10 +19,14 @@ COPY . .
|
||||
# Create a non-root user and switch to it
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S nextjs -u 1001
|
||||
|
||||
# Change ownership of the app directory to the non-root user
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
USER nextjs
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 19000
|
||||
|
||||
# Define the command to run the application
|
||||
CMD ["npm", "start"]
|
||||
# Default to production, but can be overridden
|
||||
CMD ["sh", "-c", "if [ \"$NODE_ENV\" = \"development\" ] ; then npm run dev ; else npm start ; fi"]
|
||||
Reference in New Issue
Block a user