Generate Docker configurations: multi-stage non-root images, Compose files without the obsolete version key, health checks with dependency conditions, secrets, log rotation and CI builds.
.devin/rules/windsurf-docker-configuration.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
When generating Docker configuration:
## Multi-stage Dockerfiles
- Build in one stage and copy only runtime artifacts into a slim final stage; pin base images to a specific version (and digest for production).
- Run as a non-root user, add a `.dockerignore` (node_modules, .git, .env, build output), and order instructions so dependency installation is cached separately from source code.
```dockerfile
# syntax=docker/dockerfile:1
FROM node:22-bookworm-slim AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM deps AS build
COPY . .
RUN npm run build && npm prune --omit=dev
FROM node:22-bookworm-slim AS runtime
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]
```
## Compose files
- Omit the top-level `version` key; it is obsolete and only produces a warning.
- Define health checks and start dependants only when dependencies are healthy:
```yaml
services:
api:
build: .
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://app@db:5432/app
secrets:
- db_password
networks:
- backend
depends_on:
db:
condition: service_healthy
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
db:
image: postgres:17
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- db-data:/var/lib/postgresql/data
networks:
- backend
networks:
backend: {}
volumes:
db-data: {}
secrets:
db_password:
file: ./secrets/db_password.txt
```
## Networking
- Publish only the ports that clients outside Docker need; databases and internal services stay on internal networks.
## Secrets
- Never put secrets in `ENV`, `ARG` or committed Compose files: build args and environment variables persist in the image. Use build secrets (`RUN --mount=type=secret,id=npmrc ...` with `docker build --secret id=npmrc,src=...`) at build time and Compose/orchestrator secrets or `*_FILE` variables at run time.
## Logging
- Write application logs to stdout/stderr and configure rotation (`max-size`, `max-file`) or a logging driver for the platform.
## CI/CD
- Build with BuildKit (`docker buildx build`) using registry or CI cache, tag images with the commit SHA, scan them, and push only from the main branch or tags.
## Documentation
- Document required environment variables and secrets, exposed ports, volumes, and the commands to build, run and test locally.
Windsurf
devops
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Windsurf workspace's docker-compose.yml starts with version: '3.8', passes DB_PASSWORD as a plain environment variable, and the API container crashes because Postgres is not ready yet.
Generate a production Dockerfile and docker-compose.yml for a Node 22 API with Postgres, following the Docker configuration rule.
A multi-stage Dockerfile that runs as the node user with a .dockerignore, and a Compose file without version that uses a Postgres healthcheck with depends_on condition: service_healthy, file-based secrets with POSTGRES_PASSWORD_FILE, log rotation options and no published database port, plus a short README section listing variables and commands.
Windsurf's rules documentation (docs.windsurf.com/windsurf/cascade/memories) now redirects to Devin documentation, which describes rules for the Devin Local agent in Devin Desktop. Current rules live in .devin/rules/*.md with a trigger setting, and the legacy Windsurf files (.windsurf/rules/*.md, .windsurf/global_rules.md and .windsurfrules) are still imported by default. AGENTS.md files are read as always-on rules.
.devin/rules/windsurf-docker-configuration.mdStarting point, not a tested configuration for your repository. Applied when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
---
trigger: glob
globs: "**/*"
---
When generating Docker configuration:
## Multi-stage Dockerfiles
- Build in one stage and copy only runtime artifacts into a slim final stage; pin base images to a specific version (and digest for production).
- Run as a non-root user, add a `.dockerignore` (node_modules, .git, .env, build output), and order instructions so dependency installation is cached separately from source code.
```dockerfile
# syntax=docker/dockerfile:1
FROM node:22-bookworm-slim AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM deps AS build
COPY . .
RUN npm run build && npm prune --omit=dev
FROM node:22-bookworm-slim AS runtime
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]
```
## Compose files
- Omit the top-level `version` key; it is obsolete and only produces a warning.
- Define health checks and start dependants only when dependencies are healthy:
```yaml
services:
api:
build: .
ports:
- "3000:3000"
environment:
DATABASE_URL: postgres://app@db:5432/app
secrets:
- db_password
networks:
- backend
depends_on:
db:
condition: service_healthy
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
db:
image: postgres:17
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- db-data:/var/lib/postgresql/data
networks:
- backend
networks:
backend: {}
volumes:
db-data: {}
secrets:
db_password:
file: ./secrets/db_password.txt
```
## Networking
- Publish only the ports that clients outside Docker need; databases and internal services stay on internal networks.
## Secrets
- Never put secrets in `ENV`, `ARG` or committed Compose files: build args and environment variables persist in the image. Use build secrets (`RUN --mount=type=secret,id=npmrc ...` with `docker build --secret id=npmrc,src=...`) at build time and Compose/orchestrator secrets or `*_FILE` variables at run time.
## Logging
- Write application logs to stdout/stderr and configure rotation (`max-size`, `max-file`) or a logging driver for the platform.
## CI/CD
- Build with BuildKit (`docker buildx build`) using registry or CI cache, tag images with the commit SHA, scan them, and push only from the main branch or tags.
## Documentation
- Document required environment variables and secrets, exposed ports, volumes, and the commands to build, run and test locally.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The docs recommend keeping rules short and specific. The current docs say AGENTS.md, AGENTS.local.md and AGENT.md are read as always-on rules, including files in subdirectories. Use .devin/rules/ when you need glob, model-decision or manual triggers.
Documentation checked 2026-11-05: Devin docs: Local customizations (redirect target of Windsurf memories docs)Windsurf docs: Cascade memories (redirects)