-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add docker setup for easy setup #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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* |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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 | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the VITE_API_BASE_URL default and its limitations. The default -ARG VITE_API_BASE_URL=http://localhost:4096
+# Note: This default is for local development only. Override for production environments.
+# Example: docker build --build-arg VITE_API_BASE_URL=https://api.example.com ...
+ARG VITE_API_BASE_URL=http://localhost:4096📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| # 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"] | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| FROM oven/bun:latest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin the bun base image to a specific version. Using -FROM oven/bun:latest AS builder
+FROM oven/bun:1.x.y # Replace x.y with the desired versionRun
🤖 Prompt for AI Agents |
||
|
|
||
| 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"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Service readiness: The Consider implementing one of the following strategies:
Option 1: Add a healthcheck to opencode service: services:
opencode:
build:
context: .
dockerfile: Dockerfile.opencode
environment:
- HOST=0.0.0.0
- PORT=4096
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:4096/health"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
ports:
- "4096:4096"
restart: unless-stoppedThen update the web service to wait for it: web:
...
depends_on:
- - opencode
+ opencode:
+ condition: service_healthyOption 2: Add a brief startup delay (simpler but less reliable): web:
...
+ command: sh -c "sleep 5 && serve -l 5173 -s dist"
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin the bun base image to a specific version.
Using
oven/bun:latestcreates reproducibility issues. Pin to a specific version tag to ensure consistent builds.🤖 Prompt for AI Agents