Files
motovaultpro/backend/Dockerfile
2025-08-23 13:02:40 -05:00

34 lines
764 B
Docker

# Backend Dockerfile for MotoVaultPro
FROM node:20
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (needed for build)
RUN npm install
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Create non-root user
RUN groupadd -r nodejs && useradd -r -g nodejs -u 1001 backend
# Change ownership of the app directory
RUN chown -R backend:nodejs /app
USER backend
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"
# Start the application
CMD ["npm", "start"]