Some checks failed
CI/CD Pipeline - Apartment API / Scan Dependencies (push) Successful in 18s
CI/CD Pipeline - Apartment API / Run Tests (push) Successful in 10m20s
CI/CD Pipeline - Apartment API / Build & Push Image (push) Failing after 3m8s
CI/CD Pipeline - Apartment API / Deploy to Production (push) Has been skipped
- Update to node:20-alpine base image - Add apk upgrade to fix OS-level vulnerabilities - Update npm to latest to fix bundled package vulnerabilities - Add scan-deps job that runs in parallel with tests - Replace deprecated --only=production with --omit=dev
34 lines
591 B
Docker
34 lines
591 B
Docker
FROM node:20-alpine
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Update Alpine packages and npm to fix security vulnerabilities
|
|
RUN apk upgrade --no-cache && \
|
|
npm install -g npm@latest
|
|
|
|
# Install Curl
|
|
RUN apk add --no-cache curl
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci --omit=dev
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs
|
|
RUN adduser -S nodejs -u 1001
|
|
|
|
# Change ownership of the app directory
|
|
RUN chown -R nodejs:nodejs /app
|
|
USER nodejs
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Start the application
|
|
CMD ["npm", "start"] |