Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Dependencies
node_modules
**/node_modules
.pnp
.pnp.js

# Testing
coverage
*.test.ts
*.test.js
*.spec.ts
*.spec.js
__tests__
__mocks__

# Build outputs (we'll copy specific ones)
**/dist
**/build
**/.next
**/out
.turbo

# Environment
.env
.env.local
.env.*.local

# Git
.git
.gitignore
.gitattributes

# IDE
.vscode
.idea
*.swp
*.swo
*~
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
lerna-debug.log*

# Misc
.changeset
*.md
!README.md
LICENSE
CODEOWNERS

# Development files
*.development.*
dev-*
tmp
temp

# Docker
Dockerfile*
docker-compose*
.dockerignore
85 changes: 85 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Stage 1: Base image with Bun and necessary tools
FROM oven/bun:1.2.19-alpine AS base

WORKDIR /app

RUN apk add --no-cache \
openssl \
postgresql-client \
curl \
nodejs

# Stage 2: Install dependencies
FROM base AS dependencies

WORKDIR /app

COPY package.json bun.lock ./

# Copy package.json files for workspace packages
COPY packages/core/package.json ./packages/core/
COPY packages/view/package.json ./packages/view/
COPY www/package.json ./www/

# Install all dependencies
RUN bun install --frozen-lockfile

# Stage 3: Build the view package
FROM dependencies AS build-view

WORKDIR /app

COPY --from=dependencies /app/node_modules ./node_modules
COPY packages/view ./packages/view

RUN bun run --cwd packages/view build

# Stage 4: Build the core package
FROM build-view AS build-core

WORKDIR /app

COPY scripts ./scripts

COPY --from=build-view /app/node_modules ./node_modules
COPY packages/core ./packages/core

RUN bun run --cwd packages/core build && bun run scripts/post-build.ts

# Stage 5: Production image
FROM oven/bun:1.2.19-alpine AS production

WORKDIR /app

# Install only essential runtime dependencies
RUN apk add --no-cache openssl

COPY package.json ./
COPY packages/core/package.json ./packages/core/
COPY www/package.json ./www/

# Install only production dependencies
RUN bun install --production --frozen-lockfile

# Copy built artifacts from core package
COPY --from=build-core /app/packages/core/dist ./packages/core/dist
COPY --from=build-core /app/packages/core/view-build ./packages/core/view-build

# Make the main entry point executable
RUN chmod +x ./packages/core/dist/index.js

# Create global symlink for core package
RUN ln -s /app/packages/core/dist/index.js /usr/local/bin/hviz

# Clean up build cache and temporary files
RUN rm -rf /tmp/* /root/.bun/install/cache

# Set environment variable for production
ENV NODE_ENV=production \
PORT=3333

# Expose necessary ports
EXPOSE 3333

ENTRYPOINT ["hviz"]
CMD [ "--help" ]
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ npx hviz

# Or with bunx
bunx hviz

# Or with Docker (no installation needed)
docker run --rm -p 3000:3333 \
-v "$(pwd)/prisma":/app/prisma \
hviz --type prisma --schema /app/prisma/schema.prisma
```

That's it! hviz will guide you through the rest with interactive prompts.
Expand Down Expand Up @@ -50,6 +55,22 @@ npm install -D hviz
bun install -D hviz
```

### 🐳 Docker

Use Docker without any local installation:

```bash
# Build the image
docker build -t hviz .

# Run with your schema
docker run --rm -p 3000:3333 \
-v "$(pwd)/prisma":/app/prisma \
hviz --type prisma --schema /app/prisma/schema.prisma
```

Then open your browser at `http://localhost:3000`

---

## 🎯 Usage
Expand Down Expand Up @@ -92,6 +113,34 @@ hviz --type typeorm --schema typeorm/schema.ts
hviz --type prisma --schema prisma/schema.prisma --port 4000
```

### 🐳 Docker Usage

Run HViz in Docker with different ORMs:

```bash
# Prisma
docker run --rm -p 3000:3333 \
-v "$(pwd)/prisma":/app/prisma \
hviz --type prisma --schema /app/prisma/schema.prisma

# Drizzle
docker run --rm -p 3000:3333 \
-v "$(pwd)/drizzle":/app/drizzle \
hviz --type drizzle --schema /app/drizzle/schema.ts

# TypeORM
docker run --rm -p 3000:3333 \
-v "$(pwd)/src/entities":/app/entities \
hviz --type typeorm --schema /app/entities

# Custom port
docker run --rm -p 8080:3333 \
-v "$(pwd)/prisma":/app/prisma \
hviz --type prisma --schema /app/prisma/schema.prisma
```

Access the visualization at `http://localhost:3000` (or at `http://localhost:{HOST_PORT}` if you specified a custom port, e.g., `http://localhost:8080`)

---

## 🛠️ CLI Options
Expand Down