29 lines
516 B
Docker
29 lines
516 B
Docker
FROM node:18-alpine
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install --only=production --silent
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Use the pre-created non-root user from the Node image
|
|
# and ensure ownership is correct
|
|
RUN chown -R node:node /app
|
|
USER node
|
|
|
|
# Expose port
|
|
EXPOSE 5000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD node healthcheck.js
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"]
|