Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Git files
.git
.gitignore

# Rust build artifacts
target/
Cargo.lock

# Documentation
README.md
CLAUDE.md
CONTRIBUTING.md

# Test files
tests/

benchmarks/

# CI/CD
.github/
.github-actions/

# Development files
.env.example
release.sh
run_all_driver_tests.sh

# Python test files
test_pgsqlite_binary.py
test_pgsqlite_text.py
test_sqlite.py

# Temporary files
*.tmp
*.log

# OS files
.DS_Store
Thumbs.db
59 changes: 59 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Push

on:
push:
branches:
- main
tags:
- "v*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=auto
images: |
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern=v{{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=sha,prefix={{branch}}-,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push (multi-arch)
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Base stage for cargo-chef
FROM rust:bookworm as chef
WORKDIR /app
RUN cargo install cargo-chef

# Planner stage: Computes the recipe file
FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

# Builder stage: Caches dependencies and builds the binary
FROM chef as builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the cached layer
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --bin pgsqlite

# Runtime stage
FROM debian:bookworm-slim as runtime

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN useradd --create-home --shell /bin/bash pgsqlite

# Create data directory
RUN mkdir -p /data && chown pgsqlite:pgsqlite /data

# Copy binary from builder
COPY --from=builder /app/target/release/pgsqlite /usr/local/bin/pgsqlite

# Switch to non-root user
USER pgsqlite

# Set working directory
WORKDIR /data

# Expose PostgreSQL default port
EXPOSE 5432

# Set default database path
ENV PGSQLITE_DATABASE=/data/database.db

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD timeout 5 bash -c "</dev/tcp/localhost/5432" || exit 1

# Run pgsqlite
CMD ["pgsqlite", "--database", "/data/database.db"]
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.8'

services:
pgsqlite:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: v0.0.18
platform: linux/arm64
ports:
- "5432:5432"
volumes:
- ./data:/data
environment:
- PGSQLITE_DATABASE=/data/database.db
restart: unless-stopped
healthcheck:
test: ["CMD", "timeout", "5", "bash", "-c", "</dev/tcp/localhost/5432"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s