mirror of
https://github.com/hanzoai/base.git
synced 2026-08-05 04:22:31 +00:00
perf: Go 1.26, multi-arch native build, BuildKit cache
- Upgrade Go 1.24 -> 1.26 in go.mod and Dockerfile - Remove hardcoded GOOS/GOARCH for native multi-arch builds - Add BuildKit cache mounts for go modules and build cache - Bump Alpine 3.19 -> 3.21 in production stage - Switch docker.yml to hanzoai reusable docker-build workflow - Add .dockerignore to reduce build context - Gitignore AI agent context files
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
.git/
|
||||
.github/
|
||||
.builds/
|
||||
.vscode/
|
||||
.idea/
|
||||
docs/
|
||||
sdk/
|
||||
node_modules/
|
||||
dist/
|
||||
*.test
|
||||
*.out
|
||||
coverage.out
|
||||
*.todo
|
||||
*.html
|
||||
.DS_Store
|
||||
CLAUDE.md
|
||||
AGENTS.md
|
||||
GEMINI.md
|
||||
QWEN.md
|
||||
@@ -7,37 +7,8 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: ghcr.io/hanzoai/base
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=sha
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
docker:
|
||||
uses: hanzoai/.github/.github/workflows/docker-build.yml@main
|
||||
with:
|
||||
image: ghcr.io/hanzoai/base
|
||||
secrets: inherit
|
||||
|
||||
@@ -28,3 +28,9 @@ dist/
|
||||
|
||||
# typegen binary
|
||||
/typegen
|
||||
|
||||
# AI agent context files
|
||||
CLAUDE.md
|
||||
AGENTS.md
|
||||
GEMINI.md
|
||||
QWEN.md
|
||||
|
||||
+10
-45
@@ -1,62 +1,27 @@
|
||||
# Hanzo Base - PocketBase Fork
|
||||
# Multi-stage build for minimal production image
|
||||
|
||||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
# Install build dependencies
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM golang:1.26-alpine AS builder
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY . .
|
||||
|
||||
# Build the binary
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build \
|
||||
-ldflags="-s -w -X github.com/hanzoai/base.Version=$(git describe --tags --always 2>/dev/null || echo 'dev')" \
|
||||
-o /build/base \
|
||||
./examples/base/main.go
|
||||
|
||||
# Production stage
|
||||
FROM alpine:3.19
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache ca-certificates tzdata curl
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -S hanzo && adduser -S hanzo -G hanzo
|
||||
|
||||
FROM alpine:3.21
|
||||
RUN apk add --no-cache ca-certificates tzdata curl \
|
||||
&& addgroup -S hanzo && adduser -S hanzo -G hanzo
|
||||
WORKDIR /app
|
||||
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /build/base /app/base
|
||||
|
||||
# Copy UI if exists
|
||||
COPY --from=builder /build/ui/dist /app/hz_public
|
||||
|
||||
# Create data directories
|
||||
RUN mkdir -p /pb_data /pb_migrations /pb_hooks && \
|
||||
chown -R hanzo:hanzo /app /pb_data /pb_migrations /pb_hooks
|
||||
|
||||
RUN mkdir -p /pb_data /pb_migrations /pb_hooks && chown -R hanzo:hanzo /app /pb_data /pb_migrations /pb_hooks
|
||||
USER hanzo
|
||||
|
||||
# Expose default port
|
||||
EXPOSE 8080
|
||||
|
||||
# Environment variables
|
||||
ENV PB_ENCRYPTION_KEY=""
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/api/health || exit 1
|
||||
|
||||
# Default command
|
||||
ENTRYPOINT ["/app/base"]
|
||||
CMD ["serve", "--http=0.0.0.0:8080", "--dir=/pb_data", "--migrationsDir=/pb_migrations", "--hooksDir=/pb_hooks"]
|
||||
|
||||
Reference in New Issue
Block a user