FROM node:22-slim WORKDIR /app ARG NPM_TOKEN
ENV NPM_TOKEN=$NPM_TOKEN COPY package*.json ./ RUN npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN \ && npm ci COPY . . RUN npm run build CMD ["node", "dist/index.js"]
FROM node:22-slim WORKDIR /app ARG NPM_TOKEN
ENV NPM_TOKEN=$NPM_TOKEN COPY package*.json ./ RUN npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN \ && npm ci COPY . . RUN npm run build CMD ["node", "dist/index.js"]
FROM node:22-slim WORKDIR /app ARG NPM_TOKEN
ENV NPM_TOKEN=$NPM_TOKEN COPY package*.json ./ RUN npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN \ && npm ci COPY . . RUN npm run build CMD ["node", "dist/index.js"]
ARG OPENAI_API_KEY
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ARG OPENAI_API_KEY
ENV OPENAI_API_KEY=$OPENAI_API_KEY
ARG OPENAI_API_KEY
ENV OPENAI_API_KEY=$OPENAI_API_KEY
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app COPY package*.json ./ RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken COPY . . RUN npm run build FROM node:22-slim AS runtime WORKDIR /app ENV NODE_ENV=production COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./ RUN npm ci --omit=dev CMD ["node", "dist/index.js"]
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app COPY package*.json ./ RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken COPY . . RUN npm run build FROM node:22-slim AS runtime WORKDIR /app ENV NODE_ENV=production COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./ RUN npm ci --omit=dev CMD ["node", "dist/index.js"]
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app COPY package*.json ./ RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken COPY . . RUN npm run build FROM node:22-slim AS runtime WORKDIR /app ENV NODE_ENV=production COPY --from=build /app/dist ./dist
COPY --from=build /app/package*.json ./ RUN npm ci --omit=dev CMD ["node", "dist/index.js"]
docker build \ --secret id=npm_token,env=NPM_TOKEN \ -t ai-agent-api:local .
docker build \ --secret id=npm_token,env=NPM_TOKEN \ -t ai-agent-api:local .
docker build \ --secret id=npm_token,env=NPM_TOKEN \ -t ai-agent-api:local .
name: Build Docker Image on: pull_request: push: branches: - main jobs: docker-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v6 with: context: . push: false tags: ai-agent-api:ci secrets: | npm_token=${{ secrets.NPM_TOKEN }}
name: Build Docker Image on: pull_request: push: branches: - main jobs: docker-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v6 with: context: . push: false tags: ai-agent-api:ci secrets: | npm_token=${{ secrets.NPM_TOKEN }}
name: Build Docker Image on: pull_request: push: branches: - main jobs: docker-build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/build-push-action@v6 with: context: . push: false tags: ai-agent-api:ci secrets: | npm_token=${{ secrets.NPM_TOKEN }}
RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken
RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken
RUN --mount=type=secret,id=npm_token \ npm config set //registry.npmjs.org/:_authToken="$(cat /run/secrets/npm_token)" \ && npm ci \ && npm config delete //registry.npmjs.org/:_authToken
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends git openssh-client \ && rm -rf /var/lib/apt/lists/* RUN --mount=type=ssh \ git clone [email protected]:your-org/private-agent-tools.git tools
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends git openssh-client \ && rm -rf /var/lib/apt/lists/* RUN --mount=type=ssh \ git clone [email protected]:your-org/private-agent-tools.git tools
# syntax=docker/dockerfile:1.7 FROM node:22-slim AS build WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends git openssh-client \ && rm -rf /var/lib/apt/lists/* RUN --mount=type=ssh \ git clone [email protected]:your-org/private-agent-tools.git tools
docker build --ssh default -t ai-agent-api:local .
docker build --ssh default -t ai-agent-api:local .
docker build --ssh default -t ai-agent-api:local .
docker run \ -e OPENAI_API_KEY="$OPENAI_API_KEY" \ ai-agent-api:local
docker run \ -e OPENAI_API_KEY="$OPENAI_API_KEY" \ ai-agent-api:local
docker run \ -e OPENAI_API_KEY="$OPENAI_API_KEY" \ ai-agent-api:local
services: app: image: ai-agent-api:local environment: OPENAI_API_KEY: ${OPENAI_API_KEY} MCP_GITHUB_TOKEN: ${MCP_GITHUB_TOKEN}
services: app: image: ai-agent-api:local environment: OPENAI_API_KEY: ${OPENAI_API_KEY} MCP_GITHUB_TOKEN: ${MCP_GITHUB_TOKEN}
services: app: image: ai-agent-api:local environment: OPENAI_API_KEY: ${OPENAI_API_KEY} MCP_GITHUB_TOKEN: ${MCP_GITHUB_TOKEN}
.env
.env.*
.npmrc
.git
node_modules
coverage
dist
*.log
.env
.env.*
.npmrc
.git
node_modules
coverage
dist
*.log
.env
.env.*
.npmrc
.git
node_modules
coverage
dist
*.log
docker history ai-agent-api:local
docker history ai-agent-api:local
docker history ai-agent-api:local
docker run --rm ai-agent-api:local sh -c "find /app -type f | xargs grep -i 'sk-' || true"
docker run --rm ai-agent-api:local sh -c "find /app -type f | xargs grep -i 'sk-' || true"
docker run --rm ai-agent-api:local sh -c "find /app -type f | xargs grep -i 'sk-' || true" - Does the Dockerfile use ARG or ENV for anything that looks like a token, key, password, or credential?
- Does the build need the secret, or does only the running app need it?
- Are private npm tokens passed through --secret instead of ARG?
- Are SSH keys forwarded through --ssh instead of copied?
- Does the final runtime image avoid .npmrc, private keys, local .env files, and unnecessary build artifacts?
- Is .dockerignore excluding files such as .env, .npmrc, .git, logs, coverage output, and local test data? - Do not put secrets in ARG
- Do not promote them to ENV inside the Dockerfile
- Do not copy .env or .npmrc into the image
- Use RUN --mount=type=secret for build-time secrets
- Use --mount=type=ssh for private Git access
- Pass runtime credentials through your runtime environment or secret manager