From 2486eaaadcd60065b963bb2ec8690cb7ef1d94a0 Mon Sep 17 00:00:00 2001 From: Greg Berns Date: Thu, 6 Nov 2025 22:52:33 -0700 Subject: [PATCH] feat: Add docker setup for easy setup feat: additional refinement --- .dockerignore | 57 +++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 37 +++++++++++++++++++++++++++++ Dockerfile.opencode | 15 ++++++++++++ docker-compose.yml | 31 ++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Dockerfile.opencode create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d82a824 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,57 @@ +# Dependencies +node_modules +bun.lock + +# Build outputs +dist +build +*.tsbuildinfo + +# Development files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# IDE +.vscode +.idea +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Git +.git +.gitignore + +# Documentation +README.md +docs/ +*.md + +# Misc +.eslintrc* +.prettierrc* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2f45fa7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Build stage - using Bun for fast builds +FROM oven/bun:latest AS builder + +WORKDIR /build + +# Install git first (this layer rarely changes) +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +# Accept build argument for API base URL (this can change frequently) +ARG VITE_API_BASE_URL=http://localhost:4096 + +# Copy local source code (this changes often) +COPY . . + +# Install dependencies (changes when package.json changes) +RUN bun install + +# Build (changes when source or ARG changes) +ENV VITE_API_BASE_URL=$VITE_API_BASE_URL +RUN bun run build + +# Runtime stage - lightweight Node.js image +FROM node:20-alpine + +WORKDIR /app + +# Install serve to efficiently serve static files +RUN npm install -g serve + +# Copy built application from builder stage +COPY --from=builder /build/dist ./dist + +# Expose port 5173 (matches the dev server port used in docker-compose) +EXPOSE 5173 + +# Serve the built application +CMD ["serve", "-l", "5173", "-s", "dist"] diff --git a/Dockerfile.opencode b/Dockerfile.opencode new file mode 100644 index 0000000..d9d7ce9 --- /dev/null +++ b/Dockerfile.opencode @@ -0,0 +1,15 @@ +FROM oven/bun:latest + +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + +RUN bun install -g opencode-ai + +WORKDIR /workspace + +ENV HOST=0.0.0.0 +ENV PORT=4096 + +EXPOSE 4096 + +# For server logs, add: "--log-level INFO --print-logs true" +CMD ["sh", "-c", "opencode serve --hostname $HOST --port $PORT"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b952085 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +services: + opencode: + build: + context: . + dockerfile: Dockerfile.opencode + environment: + - HOST=0.0.0.0 + - PORT=4096 + working_dir: /workspace + # volumes: + # # Mount to a project folder + # - .:/workspace + # # Optionally you can mount the opencode files to your system + # - ./opencode-data:/home/opencode/.local/share/opencode + # - ./opencode-config:/home/opencode/.config/opencode + # - ./opencode-state:/home/opencode/.local/state/opencode + ports: + - "4096:4096" + restart: unless-stopped + + web: + build: + context: . + dockerfile: Dockerfile + args: + VITE_API_BASE_URL: http://localhost:4096 + ports: + - "5173:5173" + restart: unless-stopped + depends_on: + - opencode