Skip to content

Commit 2486eaa

Browse files
committed
feat: Add docker setup for easy setup
feat: additional refinement
1 parent 0ab3c85 commit 2486eaa

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed

.dockerignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Dependencies
2+
node_modules
3+
bun.lock
4+
5+
# Build outputs
6+
dist
7+
build
8+
*.tsbuildinfo
9+
10+
# Development files
11+
.env.local
12+
.env.development.local
13+
.env.test.local
14+
.env.production.local
15+
16+
# Logs
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
pnpm-debug.log*
21+
lerna-debug.log*
22+
23+
# Runtime data
24+
pids
25+
*.pid
26+
*.seed
27+
*.pid.lock
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# IDE
37+
.vscode
38+
.idea
39+
*.swp
40+
*.swo
41+
42+
# OS
43+
.DS_Store
44+
Thumbs.db
45+
46+
# Git
47+
.git
48+
.gitignore
49+
50+
# Documentation
51+
README.md
52+
docs/
53+
*.md
54+
55+
# Misc
56+
.eslintrc*
57+
.prettierrc*

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Build stage - using Bun for fast builds
2+
FROM oven/bun:latest AS builder
3+
4+
WORKDIR /build
5+
6+
# Install git first (this layer rarely changes)
7+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
8+
9+
# Accept build argument for API base URL (this can change frequently)
10+
ARG VITE_API_BASE_URL=http://localhost:4096
11+
12+
# Copy local source code (this changes often)
13+
COPY . .
14+
15+
# Install dependencies (changes when package.json changes)
16+
RUN bun install
17+
18+
# Build (changes when source or ARG changes)
19+
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
20+
RUN bun run build
21+
22+
# Runtime stage - lightweight Node.js image
23+
FROM node:20-alpine
24+
25+
WORKDIR /app
26+
27+
# Install serve to efficiently serve static files
28+
RUN npm install -g serve
29+
30+
# Copy built application from builder stage
31+
COPY --from=builder /build/dist ./dist
32+
33+
# Expose port 5173 (matches the dev server port used in docker-compose)
34+
EXPOSE 5173
35+
36+
# Serve the built application
37+
CMD ["serve", "-l", "5173", "-s", "dist"]

Dockerfile.opencode

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM oven/bun:latest
2+
3+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
4+
5+
RUN bun install -g opencode-ai
6+
7+
WORKDIR /workspace
8+
9+
ENV HOST=0.0.0.0
10+
ENV PORT=4096
11+
12+
EXPOSE 4096
13+
14+
# For server logs, add: "--log-level INFO --print-logs true"
15+
CMD ["sh", "-c", "opencode serve --hostname $HOST --port $PORT"]

docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
opencode:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile.opencode
6+
environment:
7+
- HOST=0.0.0.0
8+
- PORT=4096
9+
working_dir: /workspace
10+
# volumes:
11+
# # Mount to a project folder
12+
# - .:/workspace
13+
# # Optionally you can mount the opencode files to your system
14+
# - ./opencode-data:/home/opencode/.local/share/opencode
15+
# - ./opencode-config:/home/opencode/.config/opencode
16+
# - ./opencode-state:/home/opencode/.local/state/opencode
17+
ports:
18+
- "4096:4096"
19+
restart: unless-stopped
20+
21+
web:
22+
build:
23+
context: .
24+
dockerfile: Dockerfile
25+
args:
26+
VITE_API_BASE_URL: http://localhost:4096
27+
ports:
28+
- "5173:5173"
29+
restart: unless-stopped
30+
depends_on:
31+
- opencode

0 commit comments

Comments
 (0)