Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 5m24s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 10m1s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s
32 lines
791 B
Docker
32 lines
791 B
Docker
# Use official Node.js runtime as base image
|
|
FROM node:18-alpine
|
|
|
|
# Set working directory in container
|
|
WORKDIR /app
|
|
|
|
# Copy package files first (for better Docker layer caching)
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nodejs -u 1001
|
|
|
|
# Copy application code
|
|
COPY src/ ./src/
|
|
|
|
# Change ownership to nodejs user
|
|
RUN chown -R nodejs:nodejs /app
|
|
USER nodejs
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"] |