Initial: OpenClaw + Claude Pro Proxy with CI/CD
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
49
.gitea/workflows/build-deploy.yml
Normal file
49
.gitea/workflows/build-deploy.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.pitthappens.dyndns.org
|
||||
IMAGE_NAME: ragincajunbanjo/openclaw-proxy
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
||||
|
||||
- name: Deploy to local Docker
|
||||
run: |
|
||||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
cd ${{ gitea.workspace }}
|
||||
docker compose -f docker-compose.yml down --remove-orphans || true
|
||||
docker compose -f docker-compose.yml up -d openclaw
|
||||
echo "Waiting for health check..."
|
||||
for i in $(seq 1 60); do
|
||||
if curl -sf http://127.0.0.1:3456/health > /dev/null 2>&1; then
|
||||
echo "Deployment successful!"
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
echo "WARNING: Health check didn't pass within 120s"
|
||||
docker compose logs openclaw
|
||||
35
Dockerfile
Normal file
35
Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM node:20-bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git curl ca-certificates tini \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN npm install -g @anthropic-ai/claude-code
|
||||
|
||||
RUN git clone https://github.com/wende/claude-max-api-proxy.git /opt/claude-max-api-proxy \
|
||||
&& cd /opt/claude-max-api-proxy \
|
||||
&& npm install \
|
||||
&& npm run build
|
||||
|
||||
RUN git clone --depth 1 https://github.com/openclaw/openclaw.git /opt/openclaw \
|
||||
&& cd /opt/openclaw \
|
||||
&& corepack enable \
|
||||
&& pnpm install --frozen-lockfile \
|
||||
&& pnpm build
|
||||
|
||||
RUN useradd -m -u 1000 -s /bin/bash openclaw || true
|
||||
RUN mkdir -p /home/openclaw/.claude \
|
||||
/home/openclaw/.openclaw \
|
||||
/home/openclaw/.openclaw/workspace \
|
||||
&& chown -R 1000:1000 /home/openclaw
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
USER openclaw
|
||||
WORKDIR /home/openclaw
|
||||
|
||||
EXPOSE 3456 18789 18790
|
||||
|
||||
ENTRYPOINT ["tini", "--"]
|
||||
CMD ["/usr/local/bin/entrypoint.sh"]
|
||||
49
entrypoint.sh
Normal file
49
entrypoint.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
MODE="${1:-run}"
|
||||
|
||||
if [ "$MODE" = "auth" ]; then
|
||||
echo "=== Claude Code Authentication ==="
|
||||
echo "Run 'claude login' to authenticate with your Max subscription."
|
||||
echo "Credentials are saved to the mounted volume at ~/.claude"
|
||||
echo ""
|
||||
exec claude login
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "shell" ]; then
|
||||
exec /bin/bash
|
||||
fi
|
||||
|
||||
echo "Checking Claude Code authentication..."
|
||||
if ! claude --version > /dev/null 2>&1; then
|
||||
echo "ERROR: Claude Code CLI not working."
|
||||
echo "Run: docker compose run --rm openclaw auth"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$HOME/.claude/.credentials.json" ] && [ -z "$ANTHROPIC_API_KEY" ]; then
|
||||
echo "ERROR: No Claude credentials found."
|
||||
echo "Run: docker compose run --rm openclaw auth"
|
||||
exit 1
|
||||
fi
|
||||
echo "Claude Code CLI authenticated."
|
||||
|
||||
echo "Starting claude-max-api-proxy on :3456..."
|
||||
node /opt/claude-max-api-proxy/dist/server/standalone.js &
|
||||
PROXY_PID=$!
|
||||
|
||||
for i in $(seq 1 30); do
|
||||
if curl -sf http://127.0.0.1:3456/health > /dev/null 2>&1; then
|
||||
echo "Proxy ready."
|
||||
break
|
||||
fi
|
||||
[ $i -eq 30 ] && echo "ERROR: Proxy timeout." && exit 1
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Starting OpenClaw gateway on :18789..."
|
||||
cd /opt/openclaw
|
||||
exec node dist/index.js gateway \
|
||||
--bind "${OPENCLAW_GATEWAY_BIND:-lan}" \
|
||||
--port 18789
|
||||
Reference in New Issue
Block a user