Container orchestration patterns for Google Antigravity IDE
# Docker Compose Development Guide for Google Antigravity
Master local development with Docker Compose in Google Antigravity IDE. This comprehensive guide covers multi-service configurations, networking, volumes, health checks, and production-ready patterns for containerized application development.
## Configuration
Configure your Antigravity environment for Docker:
```typescript
// .antigravity/docker.ts
export const dockerConfig = {
compose: {
version: "3.8",
profiles: ["development", "production"]
},
features: {
healthChecks: true,
volumes: true,
networking: true
}
};
```
## Development Stack
Create a complete development environment:
```yaml
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/myapp
- REDIS_URL=redis://redis:6379
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
networks:
- app-network
db:
image: postgres:16-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: myapp
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
command: redis-server --appendonly yes
networks:
- app-network
volumes:
postgres-data:
redis-data:
networks:
app-network:
driver: bridge
```
## Production Configuration
Optimize for production deployment:
```yaml
version: "3.8"
services:
app:
image: myapp:latest
build:
context: .
dockerfile: Dockerfile
target: production
ports:
- "3000:3000"
environment:
- NODE_ENV=production
env_file:
- .env.production
deploy:
replicas: 3
resources:
limits:
cpus: "0.5"
memory: 512M
restart_policy:
condition: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
depends_on:
db:
condition: service_healthy
networks:
- app-network
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
networks:
- app-network
```
## Multi-Stage Dockerfile
Build optimized images:
```dockerfile
FROM node:20-alpine AS base
WORKDIR /app
RUN corepack enable
FROM base AS deps
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build
FROM base AS production
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]
```
## Best Practices
Follow these guidelines for Docker Compose:
1. **Use health checks** - Ensure service readiness
2. **Named volumes** - Persist data properly
3. **Multi-stage builds** - Smaller production images
4. **Environment separation** - Different configs per env
5. **Resource limits** - Prevent resource exhaustion
6. **Networks** - Isolate service communication
Google Antigravity IDE provides intelligent Docker scaffolding and compose file optimization.This Docker prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their docker implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For Docker projects, consider mentioning your framework version, coding style, and any specific libraries you're using.