# Docker Patterns

> Docker and containerization best practices

- **Type:** Skill
- **Install:** `agentstack add skill-besync-labs-antigravity-ai-kit-docker-patterns`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [besync-labs](https://agentstack.voostack.com/s/besync-labs)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [besync-labs](https://github.com/besync-labs)
- **Source:** https://github.com/besync-labs/antigravity-ai-kit/tree/main/.agent/skills/docker-patterns
- **Website:** https://besync-labs.github.io/antigravity-ai-kit/

## Install

```sh
agentstack add skill-besync-labs-antigravity-ai-kit-docker-patterns
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Docker Patterns Skill

> **Purpose**: Apply Docker best practices for containerization

---

## Overview

This skill provides patterns for building efficient, secure Docker images and orchestrating containers.

---

## Dockerfile Best Practices

### Multi-Stage Build

```dockerfile
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:20-alpine AS production
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER node
EXPOSE 3000
CMD ["node", "dist/main.js"]
```

### Layer Optimization

```dockerfile
# ❌ Bad - cache invalidated on any file change
COPY . .
RUN npm install

# ✅ Good - dependencies cached separately
COPY package*.json ./
RUN npm ci
COPY . .
```

---

## Security

### Non-Root User

```dockerfile
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
```

### Minimal Base Image

```dockerfile
# ✅ Use alpine variants
FROM node:20-alpine

# ✅ Or distroless
FROM gcr.io/distroless/nodejs20-debian12
```

---

## Docker Compose

### Development Setup

```yaml
version: "3.8"

services:
  app:
    build:
      context: .
      target: development
    volumes:
      - .:/app
      - /app/node_modules
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=development
    depends_on:
      - db
      - redis

  db:
    image: postgres:16-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: app_dev
    ports:
      - "5432:5432"

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

volumes:
  postgres_data:
```

---

## Health Checks

```dockerfile
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
```

---

## .dockerignore

```
node_modules
npm-debug.log
.git
.env
.env.*
dist
coverage
.DS_Store
*.md
!README.md
```

---

## Quick Reference

| Pattern       | Purpose           |
| :------------ | :---------------- |
| Multi-stage   | Smaller images    |
| Alpine base   | Minimal footprint |
| Non-root user | Security          |
| Layer caching | Faster builds     |
| Health checks | Orchestration     |
| .dockerignore | Exclude files     |
| Compose       | Local development |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [besync-labs](https://github.com/besync-labs)
- **Source:** [besync-labs/antigravity-ai-kit](https://github.com/besync-labs/antigravity-ai-kit)
- **License:** MIT
- **Homepage:** https://besync-labs.github.io/antigravity-ai-kit/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-besync-labs-antigravity-ai-kit-docker-patterns
- Seller: https://agentstack.voostack.com/s/besync-labs
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
