feat: add CD pipeline (Dockerfile, .dockerignore, cd.yml)
BuildKit → OCI tar → skopeo push to Gitea registry → infra repo image tag patch → Flux reconciles new pod on koala.
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.git
|
||||||
|
.gitea
|
||||||
|
.worktrees
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
||||||
|
.env*
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
bin/
|
||||||
|
brain/
|
||||||
68
.gitea/workflows/cd.yml
Normal file
68
.gitea/workflows/cd.yml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
name: cd
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Build and deploy
|
||||||
|
needs: [check]
|
||||||
|
runs-on: self-hosted
|
||||||
|
env:
|
||||||
|
SERVICE: supervisor
|
||||||
|
IMAGE: gitea.d-ma.be/mathias/supervisor
|
||||||
|
INFRA_REPO: git@gitea.d-ma.be:mathias/infra.git
|
||||||
|
BUILDKIT_HOST: unix:///run/buildkit/buildkitd.sock
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
trap 'rm -f /tmp/supervisor-image.tar' EXIT
|
||||||
|
IMAGE_TAG="${{ github.sha }}"
|
||||||
|
echo "Building ${IMAGE}:${IMAGE_TAG}"
|
||||||
|
|
||||||
|
# Build to local OCI tar (no registry auth needed at build time)
|
||||||
|
buildctl --addr "${BUILDKIT_HOST}" build \
|
||||||
|
--frontend dockerfile.v0 \
|
||||||
|
--local context=. \
|
||||||
|
--local dockerfile=. \
|
||||||
|
--opt build-arg:VERSION="${IMAGE_TAG}" \
|
||||||
|
--output type=oci,dest=/tmp/supervisor-image.tar
|
||||||
|
|
||||||
|
# Push with skopeo using simple credential flag (avoids OAuth token flow)
|
||||||
|
skopeo copy \
|
||||||
|
oci-archive:/tmp/supervisor-image.tar \
|
||||||
|
docker://${IMAGE}:${IMAGE_TAG} \
|
||||||
|
--dest-creds "${{ secrets.REGISTRY_CREDS }}"
|
||||||
|
|
||||||
|
echo "Built and pushed ${IMAGE}:${IMAGE_TAG}"
|
||||||
|
|
||||||
|
- name: Update infra repo
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
trap 'rm -rf /tmp/infra-update; rm -f ~/.ssh/infra_deploy_key' EXIT
|
||||||
|
IMAGE_TAG="${{ github.sha }}"
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.INFRA_DEPLOY_KEY }}" > ~/.ssh/infra_deploy_key
|
||||||
|
chmod 600 ~/.ssh/infra_deploy_key
|
||||||
|
ssh-keyscan gitea.d-ma.be >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
|
GIT_SSH_COMMAND="ssh -i ~/.ssh/infra_deploy_key -o IdentitiesOnly=yes" \
|
||||||
|
git clone "${INFRA_REPO}" /tmp/infra-update
|
||||||
|
|
||||||
|
cd /tmp/infra-update
|
||||||
|
sed -i "s|gitea.d-ma.be/mathias/supervisor:.*|gitea.d-ma.be/mathias/supervisor:${IMAGE_TAG}|" \
|
||||||
|
"k3s/apps/${SERVICE}/deployment.yaml"
|
||||||
|
|
||||||
|
git config user.email "cd-bot@d-ma.be"
|
||||||
|
git config user.name "CD Bot"
|
||||||
|
git add "k3s/apps/${SERVICE}/deployment.yaml"
|
||||||
|
git commit -m "chore(deploy): ${SERVICE} → ${IMAGE_TAG}"
|
||||||
|
GIT_SSH_COMMAND="ssh -i ~/.ssh/infra_deploy_key -o IdentitiesOnly=yes" \
|
||||||
|
git push
|
||||||
|
|
||||||
|
echo "Infra repo updated: ${SERVICE} → ${IMAGE_TAG}"
|
||||||
50
Dockerfile
Normal file
50
Dockerfile
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# ── Build stage ───────────────────────────────────────────────────────────────
|
||||||
|
FROM golang:1.26-bookworm AS builder
|
||||||
|
|
||||||
|
ARG VERSION=dev
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
||||||
|
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" \
|
||||||
|
-o /out/supervisor ./cmd/supervisor
|
||||||
|
|
||||||
|
# ── Runtime stage ─────────────────────────────────────────────────────────────
|
||||||
|
# Node.js 22 slim — needed for claude CLI subprocess
|
||||||
|
FROM node:22-slim
|
||||||
|
|
||||||
|
# Install claude CLI (provides the `claude` binary the supervisor shells out to)
|
||||||
|
RUN npm install -g @anthropic-ai/claude-code \
|
||||||
|
&& claude --version \
|
||||||
|
&& echo "claude CLI installed"
|
||||||
|
|
||||||
|
# Copy supervisor binary
|
||||||
|
COPY --from=builder /out/supervisor /usr/local/bin/supervisor
|
||||||
|
|
||||||
|
# Bake in config (models.yaml + skill discipline files)
|
||||||
|
COPY config/ /app/config/
|
||||||
|
|
||||||
|
# Run as non-root
|
||||||
|
RUN groupadd -r supervisor && useradd -r -g supervisor -d /app supervisor
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# brain/ is writable state — mount a PersistentVolume here
|
||||||
|
VOLUME /app/brain
|
||||||
|
|
||||||
|
ENV SUPERVISOR_CONFIG_DIR=/app/config/supervisor
|
||||||
|
ENV SUPERVISOR_MODELS_FILE=/app/config/models.yaml
|
||||||
|
ENV SUPERVISOR_BRAIN_DIR=/app/brain
|
||||||
|
ENV SUPERVISOR_SESSIONS_DIR=/app/brain/sessions
|
||||||
|
ENV SUPERVISOR_PORT=3200
|
||||||
|
|
||||||
|
USER supervisor
|
||||||
|
|
||||||
|
EXPOSE 3200
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/supervisor"]
|
||||||
Reference in New Issue
Block a user