Skip to content

Commit fc5235c

Browse files
authored
feat: add DevContainer setup (#28)
1 parent 62cd318 commit fc5235c

3 files changed

Lines changed: 82 additions & 1 deletion

File tree

.devcontainer/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# --- base image ---
2+
FROM postgres:17-bookworm AS base
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update \
7+
&& apt-get install -y --no-install-recommends ca-certificates curl \
8+
&& update-ca-certificates \
9+
&& sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
10+
&& apt-get update
11+
12+
# --- pgrx builder base image
13+
FROM base AS pgrx_builder_base
14+
15+
ENV DEBIAN_FRONTEND=noninteractive
16+
ENV PG_MAJOR=17
17+
18+
RUN apt-get -qy install curl gnupg apt-transport-https \
19+
libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev \
20+
libssl-dev libxml2-utils xsltproc ccache \
21+
build-essential git pkg-config libssl-dev clang libclang-dev \
22+
postgresql-server-dev-$PG_MAJOR postgresql-common \
23+
postgresql-common-dev protobuf-compiler libprotobuf-dev \
24+
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
25+
26+
# --- etcd_fdw image ---
27+
FROM pgrx_builder_base AS etcd_fdw_builder
28+
29+
ENV CARGO_PGRX_VERSION=0.16.1
30+
ENV PATH="/root/.cargo/bin:${PATH}"
31+
32+
RUN . $HOME/.cargo/env \
33+
&& rustup component add clippy rustfmt rust-src \
34+
&& cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}" \
35+
&& cargo pgrx init --pg$PG_MAJOR $(which pg_config)

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "rust-dev",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/common-utils:2": {},
8+
"git": "latest"
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"settings": {
13+
"terminal.integrated.shell.linux": "/bin/bash"
14+
},
15+
"extensions": [
16+
"rust-lang.rust-analyzer",
17+
"serayuzgur.crates"
18+
]
19+
}
20+
},
21+
"mounts": [
22+
"source=cargo-home,target=/usr/local/cargo,type=volume",
23+
"source=cargo-registry,target=/usr/local/cargo/registry,type=volume",
24+
"source=cargo-target,target=/workspace/target,type=volume"
25+
]
26+
}

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22

33
A foreign data wrapper around etcd for postgres
44

5-
## Setup
5+
## Development Setup
6+
7+
### Option 1: Using DevContainer
8+
9+
The easiest way to get started is using the provided DevContainer configuration:
10+
11+
1. **Prerequisites**
12+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) or Docker Engine
13+
- [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
14+
15+
2. **Open in DevContainer**
16+
- Open this project in VS Code
17+
- Press `F1` and select "Dev Containers: Reopen in Container"
18+
- Wait for the container to build (~4 minutes first time)
19+
20+
3. **Start Developing**
21+
- All dependencies are pre-installed (Rust, cargo-pgrx, PostgreSQL 17, protobuf)
22+
- Cargo cache volumes ensure fast rebuilds
23+
- Run `cargo pgrx run` to build and test
24+
25+
### Option 2: Manual Setup
626

727
- Install pgrx on your machine `cargo install --locked cargo-pgrx --version 0.16.1`
828
- Setup pgrx `cargo pgrx init`

0 commit comments

Comments
 (0)