### SYSTEM GENERATED FILE, MAKE CHANGES AS NEEDED ### # Use a specific version as the base image for the builder stage FROM node:20-alpine AS builder # Set /app as the working directory in the builder stage WORKDIR /app ### UNCOMMENT AS NEEDED ### # Copy package.json and package-lock.json into the builder stage # This allows the dependencies to be installed before copying the rest of the application code COPY package*.json ./ ### DEFAULT BOOTSTRAP BUILD CODE, RUN LOCALLY TO GENERATE package.json ### # If package.json exists and not empty, install the listed packages # If it doesn't exist or is empty, print a message and skip the installation RUN if [ -s package.json ]; then \ npm ci --omit=dev \ else \ echo "No package.json found or file is empty, skipping installation"; \ fi # Copy the rest of the application code into the builder stage COPY . /app # Start a new stage with a distroless image for smaller image size and improved security FROM gcr.io/distroless/nodejs18-debian11 # Copy the /app directory from the builder stage into the current stage # This includes the application code and the installed packages COPY --from=builder /app /app # Set /app as the working directory in the current stage WORKDIR /app # Set the command to run when the container starts # This will start the application by running index file CMD [ "index.js" ]