Skip to content

Commit 6bf3367

Browse files
committed
add dockerfile
1 parent 7574fb8 commit 6bf3367

File tree

9 files changed

+1975
-1603
lines changed

9 files changed

+1975
-1603
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
.git
3+
dist
4+
.env
5+
coverage
6+
.vscode
7+
.DS_Store
8+
*.log

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ PORT=5053
1414
DEBUG=false
1515

1616
# Amp Configuration
17+
AMP_API_KEY=
1718
AMP_SERVER_URL=https://ampcode.com

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build stage
2+
FROM node:20-alpine AS builder
3+
4+
RUN corepack enable
5+
WORKDIR /app
6+
7+
# Copy package files and install all dependencies
8+
COPY package.json pnpm-lock.yaml ./
9+
RUN pnpm install --frozen-lockfile
10+
11+
# Copy source and build
12+
COPY . .
13+
RUN pnpm run build
14+
15+
# Runtime stage
16+
FROM node:20-alpine
17+
18+
RUN corepack enable
19+
WORKDIR /app
20+
21+
ENV NODE_ENV=production \
22+
PORT=5053 \
23+
GITHUB_APP_CWD=/app
24+
25+
# Copy package files and install production dependencies only
26+
COPY package.json pnpm-lock.yaml ./
27+
RUN pnpm install --prod --frozen-lockfile
28+
29+
# Copy built application and config
30+
COPY --from=builder /app/dist ./dist
31+
COPY config.yml ./
32+
33+
EXPOSE 5053
34+
35+
CMD ["node", "dist/server.js"]

README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,56 @@ A GitHub App for automated code reviews using Hono.js and Amp.
1313

1414
## Quick Start
1515

16+
### Local Development
17+
1618
1. **Clone and Install**
1719
```bash
1820
cd cra-github
1921
pnpm install
2022
```
2123

22-
2. **Environment Setup**
24+
2. **Build (required for MCP server)**
25+
```bash
26+
pnpm run build
27+
```
28+
29+
3. **Environment Setup**
2330
```bash
2431
cp .env.example .env
2532
```
2633

27-
3. **Start Development Server**
34+
4. **Start Development Server**
2835
```bash
2936
pnpm run dev
3037
```
3138

32-
4. **Install the App**
33-
- Visit `{APP_BASE_URL}/github/install` (e.g., `https://your-ngrok-url.app/github/install`)
34-
- Follow the GitHub App installation flow
39+
### Docker Setup
40+
41+
1. **Create GitHub App**
42+
- Go to GitHub Settings > Developer settings > GitHub Apps > New GitHub App
43+
- Set webhook URL to placeholder (e.g., `https://example.com/webhook`)
44+
- Download private key, note App ID and webhook secret
45+
46+
2. **Configure Environment**
47+
```bash
48+
cp .env.example .env
49+
# Fill in GitHub App credentials from step 1
50+
# For Docker, use GITHUB_APP_PRIVATE_KEY (base64) instead of file path:
51+
# cat private-key.pem | base64 -w 0
52+
```
53+
54+
3. **Start Container**
55+
```bash
56+
docker compose up --build
57+
# or with Podman: podman-compose up --build
58+
```
59+
60+
4. **Update Webhook URL**
61+
- For local dev: start ngrok (`ngrok http 5053`)
62+
- Update GitHub App webhook URL to `https://your-url/github/webhook`
63+
64+
5. **Install the App**
65+
- Visit `http://localhost:5053/github/install`
3566
- Select repositories to enable code reviews
3667

3768
## Configuration

config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ amp:
3131
command: "sh"
3232
args:
3333
- "-c"
34-
- "cd ${GITHUB_APP_CWD} && pnpm run mcp"
34+
- "cd ${GITHUB_APP_CWD} && node dist/mcp/server.js 2>&1 | tee /tmp/mcp-server.log"
3535
env:
3636
GITHUB_APP_CWD: "${GITHUB_APP_CWD}"
3737
GITHUB_APP_ID: "${GITHUB_APP_ID}"

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
cra:
3+
build: .
4+
env_file: .env
5+
environment:
6+
GITHUB_APP_CWD: /app # Override .env value for container
7+
ports:
8+
- "5053:5053"
9+
init: true
10+
restart: unless-stopped

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"main": "dist/app.js",
77
"scripts": {
8+
"predev": "tsc",
89
"dev": "tsx watch src/server.ts",
910
"build": "tsc",
1011
"start": "node dist/server.js",

0 commit comments

Comments
 (0)