Nx docker

From qauth-labs/qauth · View interactive version

Nx docker is an AI agent skill from the GitHub repository qauth-labs/qauth. Docker and containerization for Nx projects. Use when building images, managing containers, or working with docker-compose.

How to use this skill

Skill file

Docker & Containerization

Development Stack

# Start services
docker compose up -d
docker compose up -d postgres redis

# Logs
docker compose logs -f

# Stop
docker compose down
docker compose down -v  # Remove volumes

Services

| Service | Port | Purpose |

| ---------- | ---- | ------------- |

| postgres | 5432 | PostgreSQL 18 |

| redis | 6379 | Redis 7 cache |

Building Images

# Build with Nx
pnpm nx build auth-server --configuration=production

# Build Docker image
docker build -t qauth/auth-server:latest -f apps/auth-server/Dockerfile .

# Prune for minimal image
pnpm nx run auth-server:prune

Multi-Stage Build Pattern

# Stage 1: Build
FROM node:26-alpine AS builder
WORKDIR /app
RUN npm install --global pnpm@12.14.0
COPY . .
RUN pnpm install --frozen-lockfile
RUN pnpm nx build auth-server --configuration=production
RUN pnpm nx run auth-server:prune

# Stage 2: Run
FROM node:26-alpine AS runner
WORKDIR /app
RUN npm install --global pnpm@12.14.0
COPY --from=builder /app/dist/apps/auth-server .
RUN pnpm install --prod --frozen-lockfile
CMD ["node", "main.js"]

Fresh Dev Setup

docker compose up -d postgres redis
docker compose exec postgres pg_isready -U postgres
pnpm nx run infra-db:db:migrate
pnpm nx run infra-db:db:seed
pnpm nx serve auth-server

Debugging

docker compose exec postgres bash
docker compose exec postgres psql -U postgres -d qauth
docker compose exec redis redis-cli

Cleanup

docker compose down           # Stop containers
docker compose down -v        # Remove volumes
docker compose down --rmi local  # Remove images

Testcontainers

import { PostgreSqlContainer } from '@testcontainers/postgresql';

const container = await new PostgreSqlContainer().withDatabase('qauth_test').start();
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.