diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..0b4decb --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,35 @@ +# --- base image --- +FROM postgres:17-bookworm AS base + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates curl \ + && update-ca-certificates \ + && sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \ + && apt-get update + +# --- pgrx builder base image +FROM base AS pgrx_builder_base + +ENV DEBIAN_FRONTEND=noninteractive +ENV PG_MAJOR=17 + +RUN apt-get -qy install curl gnupg apt-transport-https \ + libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev \ + libssl-dev libxml2-utils xsltproc ccache \ + build-essential git pkg-config libssl-dev clang libclang-dev \ + postgresql-server-dev-$PG_MAJOR postgresql-common \ + postgresql-common-dev protobuf-compiler libprotobuf-dev \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +# --- etcd_fdw image --- +FROM pgrx_builder_base AS etcd_fdw_builder + +ENV CARGO_PGRX_VERSION=0.16.1 +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN . $HOME/.cargo/env \ + && rustup component add clippy rustfmt rust-src \ + && cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}" \ + && cargo pgrx init --pg$PG_MAJOR $(which pg_config) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3365e43 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +{ + "name": "rust-dev", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "git": "latest" + }, + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "extensions": [ + "rust-lang.rust-analyzer", + "serayuzgur.crates" + ] + } + }, + "mounts": [ + "source=cargo-home,target=/usr/local/cargo,type=volume", + "source=cargo-registry,target=/usr/local/cargo/registry,type=volume", + "source=cargo-target,target=/workspace/target,type=volume" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 067c22b..744bdf7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,27 @@ A foreign data wrapper around etcd for postgres -## Setup +## Development Setup + +### Option 1: Using DevContainer + +The easiest way to get started is using the provided DevContainer configuration: + +1. **Prerequisites** + - [Docker Desktop](https://www.docker.com/products/docker-desktop/) or Docker Engine + - [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + +2. **Open in DevContainer** + - Open this project in VS Code + - Press `F1` and select "Dev Containers: Reopen in Container" + - Wait for the container to build (~4 minutes first time) + +3. **Start Developing** + - All dependencies are pre-installed (Rust, cargo-pgrx, PostgreSQL 17, protobuf) + - Cargo cache volumes ensure fast rebuilds + - Run `cargo pgrx run` to build and test + +### Option 2: Manual Setup - Install pgrx on your machine `cargo install --locked cargo-pgrx --version 0.16.1` - Setup pgrx `cargo pgrx init`