Skip to content

Commit 3bebe58

Browse files
sudaclaude
andcommitted
feat: Implement deployment and CI/CD workflows (Issue #8)
- Add release workflow for automated GitHub releases on version tags - Add version-bump workflow for semantic versioning - Add bridge server Dockerfile for containerized deployment - Add production docker-compose configuration - Add installation documentation (docs/INSTALLATION.md) - Add bridge server update script (scripts/update-bridge.sh) - Add plugin health check endpoint (server/health.go) - Enhance bridge server health endpoint with version and uptime Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 718e37e commit 3bebe58

8 files changed

Lines changed: 549 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Build and Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.21'
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '22'
28+
29+
- name: Install frontend dependencies
30+
run: cd webapp && npm ci
31+
32+
- name: Build for all platforms
33+
run: make build-all
34+
35+
- name: Create bundles
36+
run: make bundle-all
37+
38+
- name: Create Release
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
files: |
42+
dist/com.appsome.claudecode-linux-amd64.tar.gz
43+
dist/com.appsome.claudecode-darwin-amd64.tar.gz
44+
dist/com.appsome.claudecode-windows-amd64.tar.gz
45+
generate_release_notes: true
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/version-bump.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Version Bump
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version type (major, minor, patch)'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
bump:
21+
name: Bump Version
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '22'
33+
34+
- name: Install semver
35+
run: npm install -g semver
36+
37+
- name: Bump version
38+
id: bump
39+
run: |
40+
current=$(jq -r '.version' plugin.json)
41+
new=$(semver $current -i ${{ github.event.inputs.version }})
42+
echo "current=$current" >> $GITHUB_OUTPUT
43+
echo "new=$new" >> $GITHUB_OUTPUT
44+
jq ".version = \"$new\"" plugin.json > tmp.json
45+
mv tmp.json plugin.json
46+
echo "Bumped version from $current to $new"
47+
48+
- name: Commit and tag
49+
run: |
50+
git config user.name "github-actions[bot]"
51+
git config user.email "github-actions[bot]@users.noreply.github.com"
52+
git add plugin.json
53+
git commit -m "chore: bump version to ${{ steps.bump.outputs.new }}"
54+
git tag -a "v${{ steps.bump.outputs.new }}" -m "Release v${{ steps.bump.outputs.new }}"
55+
git push origin main --tags

bridge-server/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM node:22-alpine
2+
3+
# Install build dependencies for native modules (better-sqlite3)
4+
RUN apk add --no-cache python3 make g++
5+
6+
WORKDIR /app
7+
8+
# Copy package files
9+
COPY package*.json ./
10+
11+
# Install dependencies
12+
RUN npm ci --only=production
13+
14+
# Copy built application
15+
COPY dist ./dist
16+
17+
# Create data directory for SQLite database
18+
RUN mkdir -p /data
19+
20+
# Set environment variables
21+
ENV NODE_ENV=production
22+
ENV DATABASE_PATH=/data/sessions.db
23+
ENV HOST=0.0.0.0
24+
ENV PORT=3002
25+
26+
# Expose port
27+
EXPOSE 3002
28+
29+
# Health check
30+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
31+
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/health || exit 1
32+
33+
# Run the application
34+
CMD ["node", "dist/index.js"]

bridge-server/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ app.use((req: Request, res: Response, next: NextFunction) => {
3939
next();
4040
});
4141

42+
// Track server start time for uptime calculation
43+
const startTime = Date.now();
44+
4245
// Health check endpoint
4346
app.get('/health', (req: Request, res: Response) => {
4447
res.json({
45-
status: 'healthy',
46-
timestamp: Date.now(),
48+
status: 'ok',
49+
version: process.env.npm_package_version || '1.0.0',
50+
uptime: Math.floor((Date.now() - startTime) / 1000),
4751
sessions: spawner.getAllProcesses().length,
52+
timestamp: new Date().toISOString(),
4853
});
4954
});
5055

docker-compose.prod.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: '3.8'
2+
3+
services:
4+
bridge-server:
5+
build:
6+
context: ./bridge-server
7+
dockerfile: Dockerfile
8+
container_name: claude-code-bridge
9+
ports:
10+
- "3002:3002"
11+
environment:
12+
- NODE_ENV=production
13+
- DATABASE_PATH=/data/sessions.db
14+
- CLAUDE_CODE_PATH=/usr/local/bin/claude
15+
- HOST=0.0.0.0
16+
- PORT=3002
17+
- MAX_SESSIONS=100
18+
- SESSION_TIMEOUT_MS=3600000
19+
- LOG_LEVEL=info
20+
volumes:
21+
- bridge-data:/data
22+
# Mount Claude Code CLI if installed on host
23+
# - /usr/local/bin/claude:/usr/local/bin/claude:ro
24+
restart: unless-stopped
25+
healthcheck:
26+
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3002/health"]
27+
interval: 30s
28+
timeout: 10s
29+
retries: 3
30+
start_period: 10s
31+
32+
volumes:
33+
bridge-data:
34+
driver: local

docs/INSTALLATION.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# Installation Guide
2+
3+
## Prerequisites
4+
5+
- Mattermost Server 9.0+
6+
- Claude Code CLI installed on the bridge server
7+
- Node.js 22+ (for bridge server)
8+
- Go 1.21+ (for building from source)
9+
10+
## Method 1: Mattermost Marketplace (Recommended)
11+
12+
1. Log in to Mattermost as System Admin
13+
2. Go to **System Console****Plugins****Marketplace**
14+
3. Search for "Claude Code"
15+
4. Click **Install**
16+
5. Configure settings (see [Configuration](#configuration) section)
17+
6. Enable the plugin
18+
19+
## Method 2: Manual Installation
20+
21+
### Download Latest Release
22+
23+
```bash
24+
# For Linux
25+
wget https://github.com/appsome/claude-code-mattermost-plugin/releases/latest/download/com.appsome.claudecode-linux-amd64.tar.gz
26+
27+
# For macOS
28+
wget https://github.com/appsome/claude-code-mattermost-plugin/releases/latest/download/com.appsome.claudecode-darwin-amd64.tar.gz
29+
30+
# For Windows
31+
wget https://github.com/appsome/claude-code-mattermost-plugin/releases/latest/download/com.appsome.claudecode-windows-amd64.tar.gz
32+
```
33+
34+
### Upload Plugin
35+
36+
1. Go to **System Console****Plugins****Management**
37+
2. Click **Upload Plugin**
38+
3. Select the downloaded `.tar.gz` file
39+
4. Click **Upload**
40+
5. Enable the plugin
41+
42+
### Configuration
43+
44+
1. Go to **System Console****Plugins****Claude Code**
45+
2. Configure the following settings:
46+
47+
| Setting | Description | Default |
48+
|---------|-------------|---------|
49+
| Bridge Server URL | URL of the Claude Code bridge server | `http://localhost:3002` |
50+
| Claude Code CLI Path | Path to the Claude Code CLI executable | `/usr/local/bin/claude` |
51+
| Enable File Operations | Allow users to browse and edit files via dialogs | `true` |
52+
53+
3. Click **Save**
54+
55+
## Bridge Server Setup
56+
57+
The bridge server manages Claude Code CLI sessions and is required for the plugin to function.
58+
59+
### Option 1: Docker (Recommended)
60+
61+
```bash
62+
# Clone the repository
63+
git clone https://github.com/appsome/claude-code-mattermost-plugin
64+
cd claude-code-mattermost-plugin
65+
66+
# Start the bridge server
67+
docker-compose -f docker-compose.prod.yml up -d
68+
```
69+
70+
The bridge server will be available at `http://localhost:3002`.
71+
72+
### Option 2: Manual Setup
73+
74+
```bash
75+
# Clone the repository
76+
git clone https://github.com/appsome/claude-code-mattermost-plugin
77+
cd claude-code-mattermost-plugin/bridge-server
78+
79+
# Install dependencies
80+
npm install
81+
82+
# Build the server
83+
npm run build
84+
85+
# Start the server
86+
npm start
87+
```
88+
89+
### Option 3: Using PM2 (Process Manager)
90+
91+
```bash
92+
# Install PM2 globally
93+
npm install -g pm2
94+
95+
# Start the bridge server
96+
cd bridge-server
97+
npm run build
98+
pm2 start dist/index.js --name claude-code-bridge
99+
100+
# Enable startup script
101+
pm2 startup
102+
pm2 save
103+
```
104+
105+
### Environment Variables
106+
107+
Configure the bridge server using environment variables:
108+
109+
| Variable | Description | Default |
110+
|----------|-------------|---------|
111+
| `HOST` | Server bind address | `127.0.0.1` |
112+
| `PORT` | Server port | `3002` |
113+
| `DATABASE_PATH` | SQLite database path | `./data/sessions.db` |
114+
| `CLAUDE_CODE_PATH` | Path to Claude Code CLI | `/usr/local/bin/claude` |
115+
| `MAX_SESSIONS` | Maximum concurrent sessions | `100` |
116+
| `SESSION_TIMEOUT_MS` | Session timeout in milliseconds | `3600000` (1 hour) |
117+
| `LOG_LEVEL` | Logging level (debug, info, warn, error) | `info` |
118+
119+
## Verification
120+
121+
1. Open any Mattermost channel
122+
2. Type `/claude help`
123+
3. You should see the help message with available commands
124+
125+
### Available Commands
126+
127+
- `/claude <message>` - Send a message to Claude Code
128+
- `/claude start` - Start a new Claude Code session
129+
- `/claude stop` - Stop the current session
130+
- `/claude status` - Check session status
131+
- `/claude help` - Show help message
132+
133+
## Troubleshooting
134+
135+
### Plugin fails to connect to bridge server
136+
137+
1. Verify the bridge server is running:
138+
```bash
139+
curl http://localhost:3002/health
140+
```
141+
2. Check the bridge server URL in plugin settings
142+
3. Ensure there are no firewall rules blocking the connection
143+
144+
### Claude Code CLI not found
145+
146+
1. Verify Claude Code is installed:
147+
```bash
148+
which claude
149+
claude --version
150+
```
151+
2. Update the CLI path in plugin settings or bridge server environment
152+
153+
### Sessions not persisting
154+
155+
1. Check the database path is writable
156+
2. For Docker, ensure the volume is mounted correctly
157+
158+
## Updating
159+
160+
### Plugin Update
161+
162+
1. Download the latest release
163+
2. Go to **System Console****Plugins****Management**
164+
3. Upload the new version
165+
4. The plugin will be automatically updated
166+
167+
### Bridge Server Update
168+
169+
Using the update script:
170+
171+
```bash
172+
./scripts/update-bridge.sh
173+
```
174+
175+
Or manually:
176+
177+
```bash
178+
cd bridge-server
179+
git pull origin main
180+
npm install
181+
npm run build
182+
# Restart the server (method depends on how you're running it)
183+
```
184+
185+
## Security Considerations
186+
187+
- The bridge server should only be accessible from the Mattermost server
188+
- Consider using HTTPS for production deployments
189+
- Review and restrict Claude Code CLI permissions as needed
190+
- The plugin respects Mattermost channel permissions
191+
192+
## Support
193+
194+
- [GitHub Issues](https://github.com/appsome/claude-code-mattermost-plugin/issues)
195+
- [Documentation](https://github.com/appsome/claude-code-mattermost-plugin)

0 commit comments

Comments
 (0)