Skip to content

Commit ef983d2

Browse files
committed
Add Dockerfile and deploy workflow for ghcr.io/hanzoai/sql
- Dockerfile: pgvector/pgvector:pg17 base, copies init.sql, tuned postgres config - deploy.yml: builds multi-platform (amd64/arm64), pushes to GHCR and Docker Hub - Deploy jobs roll out to hanzo-k8s and lux-k8s clusters
1 parent 4582ac6 commit ef983d2

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build and Deploy Hanzo SQL
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
paths:
7+
- 'hanzo/**'
8+
- 'Dockerfile'
9+
- '.github/workflows/deploy.yml'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to GHCR
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Log in to Docker Hub
32+
uses: docker/login-action@v3
33+
with:
34+
registry: docker.io
35+
username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
38+
- name: Build and push
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
push: true
43+
platforms: linux/amd64,linux/arm64
44+
tags: |
45+
ghcr.io/hanzoai/sql:latest
46+
ghcr.io/hanzoai/sql:${{ github.sha }}
47+
docker.io/hanzoai/sql:latest
48+
cache-from: type=gha,scope=sql
49+
cache-to: type=gha,mode=max,scope=sql
50+
51+
deploy-hanzo:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Install doctl
58+
uses: digitalocean/action-doctl@v2
59+
with:
60+
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
61+
62+
- name: Configure kubectl (hanzo-k8s)
63+
run: doctl kubernetes cluster kubeconfig save do-sfo3-hanzo-k8s
64+
65+
- name: Rolling update postgres
66+
run: |
67+
kubectl -n hanzo set image statefulset/postgres \
68+
postgres=ghcr.io/hanzoai/sql:latest
69+
kubectl -n hanzo rollout status statefulset/postgres --timeout=120s
70+
71+
deploy-lux:
72+
needs: build
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Install doctl
78+
uses: digitalocean/action-doctl@v2
79+
with:
80+
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
81+
82+
- name: Configure kubectl (lux-k8s)
83+
run: doctl kubernetes cluster kubeconfig save do-sfo3-lux-k8s
84+
85+
- name: Rolling update postgres
86+
run: |
87+
kubectl -n hanzo set image statefulset/hanzo-postgres \
88+
postgres=ghcr.io/hanzoai/sql:latest
89+
kubectl -n hanzo rollout status statefulset/hanzo-postgres --timeout=120s

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG PG_VERSION=pg17
2+
3+
# Hanzo SQL: PostgreSQL + pgvector with Hanzo defaults
4+
FROM pgvector/pgvector:${PG_VERSION}
5+
6+
LABEL maintainer="dev@hanzo.ai"
7+
LABEL org.opencontainers.image.source="https://github.com/hanzoai/postgres"
8+
LABEL org.opencontainers.image.description="Hanzo SQL - PostgreSQL with pgvector and Hanzo defaults"
9+
10+
# Copy initialization scripts
11+
COPY hanzo/init.sql /docker-entrypoint-initdb.d/00-hanzo-init.sql
12+
13+
ENV POSTGRES_DB=hanzo
14+
ENV POSTGRES_USER=hanzo
15+
ENV PGDATA=/var/lib/postgresql/data/pgdata
16+
17+
EXPOSE 5432
18+
19+
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
20+
CMD pg_isready -U hanzo -d hanzo || exit 1
21+
22+
CMD ["postgres", \
23+
"-c", "shared_buffers=256MB", \
24+
"-c", "effective_cache_size=768MB", \
25+
"-c", "maintenance_work_mem=128MB", \
26+
"-c", "checkpoint_completion_target=0.9", \
27+
"-c", "wal_buffers=16MB", \
28+
"-c", "default_statistics_target=100", \
29+
"-c", "random_page_cost=1.1", \
30+
"-c", "effective_io_concurrency=200", \
31+
"-c", "work_mem=16MB", \
32+
"-c", "min_wal_size=256MB", \
33+
"-c", "max_wal_size=1GB", \
34+
"-c", "max_worker_processes=4", \
35+
"-c", "max_parallel_workers_per_gather=2", \
36+
"-c", "max_parallel_workers=4"]

0 commit comments

Comments
 (0)