From c8e537ae2d249536fff8d42436b777d58607b187 Mon Sep 17 00:00:00 2001 From: "Chanyub.Park" Date: Fri, 5 Dec 2025 22:14:07 +0900 Subject: [PATCH 1/2] build: restore Docker configuration --- .dockerignore | 39 ++++++++++++++++++++ .github/workflows/docker-build.yml | 59 ++++++++++++++++++++++++++++++ Dockerfile | 54 +++++++++++++++++++++++++++ docker-compose.yml | 23 ++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-build.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fca9dde --- /dev/null +++ b/.dockerignore @@ -0,0 +1,39 @@ +# Git files +.git +.gitignore + +# Rust build artifacts +target/ +Cargo.lock + +# Documentation +README.md +CLAUDE.md +CONTRIBUTING.md + +# Test files +tests/ +benches/ +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 diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..4b20bd7 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..824dd60 --- /dev/null +++ b/Dockerfile @@ -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 " Date: Mon, 8 Dec 2025 09:00:26 +0900 Subject: [PATCH 2/2] fix: unignore benches to fix cargo-chef build --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index fca9dde..a59ff1f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,7 +13,7 @@ CONTRIBUTING.md # Test files tests/ -benches/ + benchmarks/ # CI/CD