File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # checkov:skip=CKV_DOCKER_3:Ensure that a user for the container has been created
2- FROM node:22-slim
1+ FROM node:22-alpine
32
4- # Set the working directory
53WORKDIR /app
64
7- # Create a non-root user
8- RUN groupadd -r appuser && useradd -r -g appuser appuser
5+ RUN addgroup -S appuser && adduser -S -G appuser appuser
96
10- # Copy package files first for better layer caching
117COPY package*.json ./
128
13- # Install dependencies (this layer will be cached unless package files change)
14- RUN npm ci --only=production --quiet --no-fund --no-audit && npm cache clean --force
9+ RUN --mount=type=cache,target=/root/.npm npm ci --only=production --quiet --no-fund --no-audit && npm cache clean --force
1510
1611ENV EXPORT_CONFIG=""
1712
18- # Copy source code
1913COPY . .
2014
21- # Change ownership of the app directory to the non-root user
2215RUN chown -R appuser:appuser /app
2316
24- # Switch to non-root user
2517USER appuser
2618
27- # No healthcheck needed for one-time job containers
2819HEALTHCHECK NONE
2920
3021CMD ["node" , "index.js" ]
Original file line number Diff line number Diff line change 1- FROM node:22-slim
1+ FROM node:22-alpine
22
3- # Set the working directory
43WORKDIR /app
54
6- # Create a non-root user
7- RUN groupadd -r appuser && useradd -r -g appuser appuser
5+ RUN addgroup -S appuser && adduser -S -G appuser appuser
86
9- # Copy package files first for better layer caching
107COPY package*.json ./
118
12- # Install dependencies (this layer will be cached unless package files change)
13- RUN npm ci --only=production --quiet --no-fund --no-audit && npm cache clean --force
9+ RUN --mount=type=cache,target=/root/.npm npm ci --only=production --quiet --no-fund --no-audit && npm cache clean --force
1410
15- # Copy source code
1611COPY . .
1712
18- # Change ownership of the app directory to the non-root user
1913RUN chown -R appuser:appuser /app
2014
21- # Switch to non-root user
2215USER appuser
2316
24- # Set default port (Cloud Run will override this)
2517ENV PORT=8080
2618
27- # Expose port for Cloud Run
2819EXPOSE 8080
2920
30- # Add healthcheck
3121HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
3222 CMD node -e "require('http').get('http://localhost:$PORT/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => { process.exit(1) })" || exit 1
3323
34- # Start the function
35- CMD ["npm" , "start" ]
24+ CMD ["npx" , "functions-framework" , "--target=dataform-service" ]
You can’t perform that action at this time.
0 commit comments