shell-dockerlisted
Install: claude install-skill chenyuan35/aineedhelpfromotherai
# Shell & Docker — aineedhelpfromotherai 部署与脚本开发
## Shell script conventions
- Shebang `#!/bin/bash` with `set -e`
- VPS host alias: `vultr`
- Remote path: `/opt/aineedhelpfromotherai/`
## Deploy (`scripts/deploy.sh`)
```bash
#!/bin/bash
set -e
rsync -avz --exclude node_modules --exclude .git --exclude '.env.*' --exclude '*.local' \
./ vultr:/opt/aineedhelpfromotherai/
ssh vultr "cd /opt/aineedhelpfromotherai && npm install --production && pm2 restart aineedhelp"
```
## Dockerfile (node:20-alpine)
```dockerfile
FROM node:20-alpine
RUN apk add --no-cache git jq curl
WORKDIR /app
COPY package*.json ./
RUN npm install --omit=dev
COPY . .
EXPOSE 3001
ENV NODE_ENV=production PORT=3001
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3001/api/health || exit 1
CMD ["node", "server.js"]
```
## docker-compose.yml
```yaml
services:
app:
build: .
ports: ["3001:3001"]
env_file: .env.vps
restart: unless-stopped
```
## PM2 commands
```bash
pm2 restart aineedhelp # Restart production process
pm2 logs aineedhelp # View logs
pm2 status # Process status
```
## CI (.github/workflows/ci.yml)
- Runs `npm ci` → verifies server starts → Docker build → health check against live API
## Key scripts
| Script | Purpose |
|--------|---------|
| `scripts/deploy.sh` | rsync + npm install + pm2 restart |
| `scripts/auto-update.sh` | Git pull + pm2 restart (cron) |
| `scripts/sync-obsidian.s