.cursorrules in survivorforge/cursor-rules runs 978 words across 36 headings.
🤖 Curated collection of .cursorrules files for Cursor IDE — boost your AI coding with framework-specific rules for React, Next.js, Python, Node.js, and more
Covers
8 of the 20 section tags
In the order a file is read inHeadings
36 headings, in the order the file writes them
01Docker & Containerization — Cursor Rules
02Comprehensive rules for Docker, Docker Compose, and container best practices
03Project Context
04Tech Stack
05Dockerfile Best Practices
06Multi-Stage Build Pattern
07Stage 1: Build
08Install dependencies first (better cache utilization)
09Copy source and build
10Stage 2: Production
11Create non-root user
12Copy only production dependencies and built artifacts
13Switch to non-root user
14Python Multi-Stage
15Dockerfile Rules
16Layer Ordering (Most to Least Frequently Changed)
17Image Size Optimization
18.dockerignore
19Security
20Docker Compose
21Development Setup
22docker-compose.yml
23Compose Best Practices
24Container Runtime
25Environment Variables
26Networking
27Health Checks
28Development Workflow
29Build and start all services
30Run in background
31View logs
32Execute command in running container
33Rebuild a single service
34Clean up everything
35Production Considerations
36Common Pitfalls
Commands
14 commands this file writes down
Extracted from the file, verbatimdocker-compose*.yml
docker compose up --build
docker compose up -d
docker compose logs -f app
docker compose exec app npm run test
docker compose up --build app
docker compose down -v --rmi local
npm cache clean --force
pip --no-cache-dir
npm ci --production
node:20.11-alpine
node:latest
docker scout cves
docker-compose.override.yml
The file
rules/devops-docker/.cursorrules
First 160 of 256 lines1# Docker & Containerization — Cursor Rules
2# Comprehensive rules for Docker, Docker Compose, and container best practices
3
4## Project Context
5You are working on a project that uses Docker for containerization. Containers are used
6for local development, CI/CD pipelines, and production deployment. The codebase includes
7Dockerfiles for application services and docker-compose files for orchestrating
8multi-container environments.
9
10## Tech Stack
11- Docker Engine 24+
12- Docker Compose v2
13- Multi-stage builds
14- Container registries (Docker Hub, GitHub Container Registry, ECR)
15- Orchestration: Docker Compose (dev), Kubernetes or ECS (production)
16
17## Dockerfile Best Practices
18
19### Multi-Stage Build Pattern
20```dockerfile
21# Stage 1: Build
22FROM node:20-alpine AS builder
23WORKDIR /app
24
25# Install dependencies first (better cache utilization)
26COPY package.json package-lock.json ./
27RUN npm ci --production=false
28
29# Copy source and build
30COPY . .
31RUN npm run build
32
33# Stage 2: Production
34FROM node:20-alpine AS production
35WORKDIR /app
36
37# Create non-root user
38RUN addgroup -S appgroup && adduser -S appuser -G appgroup
39
40# Copy only production dependencies and built artifacts
41COPY --from=builder /app/package.json /app/package-lock.json ./
42RUN npm ci --production && npm cache clean --force
43
44COPY --from=builder /app/dist ./dist
45
46# Switch to non-root user
47USER appuser
48
49EXPOSE 3000
50HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
51 CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
52
53CMD ["node", "dist/server.js"]
54```
55
56### Python Multi-Stage
57```dockerfile
58FROM python:3.12-slim AS builder
59WORKDIR /app
60
61RUN pip install --no-cache-dir uv
62COPY pyproject.toml uv.lock ./
63RUN uv sync --frozen --no-dev --no-editable
64
65COPY . .
66
67FROM python:3.12-slim AS production
68WORKDIR /app
69
70RUN useradd --create-home --no-log-init appuser
71COPY --from=builder /app/.venv .venv
72COPY --from=builder /app/src ./src
73
74USER appuser
75ENV PATH="/app/.venv/bin:$PATH"
76
77EXPOSE 8000
78HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
79 CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
80
81CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
82```
83
84## Dockerfile Rules
85
86### Layer Ordering (Most to Least Frequently Changed)
871. Base image
882. System dependencies
893. Create user
904. Copy dependency manifests (package.json, requirements.txt)
915. Install dependencies
926. Copy source code
937. Build step
948. Runtime configuration (ENV, EXPOSE, HEALTHCHECK, CMD)
95
96### Image Size Optimization
97- Use `-alpine` or `-slim` base images
98- Use multi-stage builds to exclude build tools from production
99- Combine `RUN` commands to reduce layers: `RUN apt-get update && apt-get install -y ... && rm -rf /var/lib/apt/lists/*`
100- Use `.dockerignore` to exclude unnecessary files
101- Remove caches after installing packages: `npm cache clean --force`, `pip --no-cache-dir`
102- Don't install dev dependencies in production: `npm ci --production`
103
104### .dockerignore
105```
106node_modules
107.git
108.env
109.env.*
110*.md
111.vscode
112.idea
113coverage
114.nyc_output
115dist
116__pycache__
117*.pyc
118.pytest_cache
119.mypy_cache
120docker-compose*.yml
121Dockerfile*
122```
123
124### Security
125- Never run as root — create and switch to a non-root user
126- Don't store secrets in the image (use environment variables or secrets manager)
127- Pin base image versions: `node:20.11-alpine` not `node:latest`
128- Scan images for vulnerabilities: `docker scout cves`
129- Use `COPY` instead of `ADD` (ADD has extra behaviors: URL fetch, tar extraction)
130- Don't install unnecessary packages (no `vim`, `curl` in production unless needed for healthcheck)
131- Set read-only filesystem where possible: `--read-only`
132
133## Docker Compose
134
135### Development Setup
136```yaml
137# docker-compose.yml
138services:
139 app:
140 build:
141 context: .
142 dockerfile: Dockerfile
143 target: builder # Use build stage for development
144 ports:
145 - "3000:3000"
146 volumes:
147 - .:/app # Mount source for hot reload
148 - /app/node_modules # Prevent overwriting container's node_modules
149 environment:
150 - NODE_ENV=development
151 - DATABASE_URL=postgres://postgres:postgres@db:5432/appdb
152 depends_on:
153 db:
154 condition: service_healthy
155 command: npm run dev
156
157 db:
158 image: postgres:16-alpine
159 ports:
160 - "5432:5432"
96 more lines are in the file. Read the raw file.
The rest of the repository
survivorforge/cursor-rules ships 20 other instruction files
rules/api-design-rest/.cursorrulesrules/database-sql/.cursorrulesrules/docker-devops/.cursorrulesrules/go-gin/.cursorrulesrules/nextjs-14-app-router/.cursorrulesrules/nextjs-typescript/.cursorrulesrules/python-django/.cursorrulesrules/python-modern/.cursorrulesrules/react-typescript/.cursorrulesrules/rust-actix/.cursorrulesrules/rust-production/.cursorrulesrules/tailwind-ui/.cursorrulesrules/tailwindcss/.cursorrulesrules/testing-tdd/.cursorrulesrules/typescript/.cursorrulesrules/vue3-composition/.cursorrulesrules/langchain-ai/.cursorrulesrules/saas-starter/.cursorrulesrules/api-microservices/.cursorrulesrules/mobile-react-native/.cursorrules
This listing
Whoever runs survivorforge/cursor-rules can claim it
This is yours? Claim this config and we will write to you when the measurement moves. The check is one token placed where only you can place it, and there is no account and no password.