Skip to content

Commit 505e226

Browse files
committed
feat: add release hardening, auth, CI, and deployment
1 parent 17e7cf8 commit 505e226

19 files changed

Lines changed: 495 additions & 22 deletions

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ContentPipe service
2+
CONTENTPIPE_HOST=0.0.0.0
3+
CONTENTPIPE_PORT=8765
4+
CONTENTPIPE_PUBLIC_BASE_URL=http://localhost:8765
5+
CONTENTPIPE_AUTH_TOKEN=change-me
6+
CONTENTPIPE_NOTIFY_CHANNEL=
7+
CONTENTPIPE_LOG_LEVEL=INFO
8+
9+
# OpenClaw Gateway
10+
OPENCLAW_GATEWAY_URL=http://host.docker.internal:18789
11+
12+
# Optional publishing credentials
13+
WECHAT_APPID=
14+
WECHAT_SECRET=

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 15
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: ["3.11", "3.12"]
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
cache: pip
28+
cache-dependency-path: |
29+
requirements.txt
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -r requirements.txt pytest
34+
- name: Compile check
35+
run: python -m compileall scripts
36+
- name: Run tests
37+
run: pytest -q

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Thumbs.db
2323
# Secrets / local config
2424
.env
2525
.env.*
26+
!.env.example
2627
settings.local.yaml
2728

2829
# Build artifacts

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Contributing
2+
3+
Thanks for contributing to ContentPipe.
4+
5+
## Local Setup
6+
7+
```bash
8+
python3 -m venv .venv
9+
source .venv/bin/activate
10+
pip install -r requirements.txt
11+
pip install pytest
12+
./start.sh start
13+
```
14+
15+
## Before Opening a PR
16+
17+
Please run:
18+
19+
```bash
20+
python3 -m compileall scripts
21+
pytest
22+
```
23+
24+
## Commit Style
25+
26+
Prefer Conventional Commits:
27+
28+
- `feat:` new feature
29+
- `fix:` bug fix
30+
- `docs:` documentation only
31+
- `refactor:` internal restructuring
32+
- `test:` tests
33+
- `chore:` maintenance
34+
35+
## Scope
36+
37+
Small, focused PRs are preferred.
38+
If you touch prompts, config, templates, and code together, explain why in the PR body.

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
COPY requirements.txt ./
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
COPY . .
12+
13+
EXPOSE 8765
14+
15+
CMD ["python3", "-m", "uvicorn", "web.app:app", "--app-dir", "scripts", "--host", "0.0.0.0", "--port", "8765"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 ssp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ CONTENTPIPE_PORT=8765
198198
CONTENTPIPE_HOST=0.0.0.0
199199
CONTENTPIPE_NOTIFY_CHANNEL=<discord_channel_id>
200200
CONTENTPIPE_PUBLIC_BASE_URL=http://localhost:8765
201+
CONTENTPIPE_AUTH_TOKEN=change-me
202+
CONTENTPIPE_LOG_LEVEL=INFO
201203

202204
WECHAT_APPID=...
203205
WECHAT_SECRET=...
@@ -209,6 +211,7 @@ ANTHROPIC_API_KEY=...
209211
说明:
210212
- `CONTENTPIPE_NOTIFY_CHANNEL` 为空时,不会发送 Discord 通知
211213
- `CONTENTPIPE_PUBLIC_BASE_URL` 用于 Discord 通知里的回链地址
214+
- `CONTENTPIPE_AUTH_TOKEN` 非空时,Web UI / API 会开启鉴权(浏览器登录或请求头 `X-ContentPipe-Token`
212215
- 发布相关密钥建议只通过环境变量或本地未跟踪配置注入
213216

214217
---
@@ -225,14 +228,27 @@ ANTHROPIC_API_KEY=...
225228
./start.sh restart
226229
```
227230

228-
### 6.2 直接启动 uvicorn
231+
### 6.2 Docker 一键部署(推荐给外部用户)
232+
233+
```bash
234+
cp .env.example .env
235+
# 修改 .env 里的 CONTENTPIPE_AUTH_TOKEN / OPENCLAW_GATEWAY_URL
236+
237+
docker compose up -d --build
238+
```
239+
240+
启动后:
241+
- Web UI: `http://localhost:8765`
242+
- 首次访问会要求输入 `CONTENTPIPE_AUTH_TOKEN`
243+
244+
### 6.3 直接启动 uvicorn
229245

230246
```bash
231247
cd scripts
232248
python3 -m uvicorn web.app:app --host 0.0.0.0 --port 8765
233249
```
234250

235-
### 6.3 健康检查
251+
### 6.4 健康检查
236252

237253
```bash
238254
curl http://localhost:8765/api/health
@@ -378,12 +394,16 @@ git push origin main
378394

379395
---
380396

381-
## 12. License / 使用说明
397+
## 12. License / 开源配套文件
382398

383-
仓库当前未附带正式许可证文件;在公开发布前,建议补充
399+
仓库当前已经补齐以下公开发布基础文件
384400

385-
- `LICENSE`
401+
- `LICENSE`(MIT)
386402
- `CONTRIBUTING.md`
387403
- `SECURITY.md`
388404

389-
如果你计划公开给其他人部署,这三项最好补齐。
405+
如果你准备正式 release,建议下一步继续补:
406+
407+
- `CHANGELOG.md`
408+
- GitHub Release notes
409+
- 部署示例截图 / demo 数据

SECURITY.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Current maintained line:
6+
7+
- `0.7.x`
8+
9+
## Reporting a Vulnerability
10+
11+
Please do **not** open a public GitHub issue for security-sensitive findings.
12+
13+
Instead, report privately to the maintainer with:
14+
15+
- affected version / commit
16+
- reproduction steps
17+
- expected vs actual behavior
18+
- impact assessment
19+
- suggested fix (optional)
20+
21+
## Deployment Guidance
22+
23+
Before exposing ContentPipe beyond localhost, you should:
24+
25+
- set `CONTENTPIPE_AUTH_TOKEN`
26+
- place the service behind HTTPS / reverse proxy
27+
- restrict network exposure where possible
28+
- keep API keys in environment variables, not committed files
29+
- review upload limits and publishing credentials

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3.9"
2+
3+
services:
4+
contentpipe:
5+
build: .
6+
container_name: contentpipe
7+
restart: unless-stopped
8+
ports:
9+
- "8765:8765"
10+
env_file:
11+
- .env
12+
extra_hosts:
13+
- "host.docker.internal:host-gateway"
14+
volumes:
15+
- ./output:/app/output

scripts/logutil.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import annotations
2+
3+
import logging
4+
import os
5+
6+
_LEVEL = os.environ.get("CONTENTPIPE_LOG_LEVEL", "INFO").upper()
7+
8+
logging.basicConfig(
9+
level=getattr(logging, _LEVEL, logging.INFO),
10+
format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
11+
)
12+
13+
14+
def get_logger(name: str) -> logging.Logger:
15+
return logging.getLogger(name)

0 commit comments

Comments
 (0)