Skip to content

Commit 4a65638

Browse files
committed
Merge branch 'main' into issue-26
2 parents 6e9a779 + 5b587af commit 4a65638

2 files changed

Lines changed: 56 additions & 32 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,57 @@
1-
# --- base image ---
2-
FROM postgres:17-bookworm AS base
1+
FROM debian:bookworm-slim
32

43
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV PG_MAJOR=17
55

6+
# Install system dependencies
67
RUN apt-get update \
7-
&& apt-get install -y --no-install-recommends ca-certificates curl \
8+
&& apt-get install -y --no-install-recommends \
9+
ca-certificates curl gnupg apt-transport-https \
10+
build-essential git pkg-config \
11+
libreadline-dev zlib1g-dev flex bison \
12+
libxml2-dev libxslt-dev libssl-dev \
13+
libxml2-utils xsltproc ccache \
14+
clang libclang-dev \
15+
protobuf-compiler libprotobuf-dev \
16+
sudo \
817
&& 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-
18+
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
19+
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
20+
&& apt-get update \
21+
&& apt-get install -y --no-install-recommends \
22+
postgresql-$PG_MAJOR \
23+
postgresql-server-dev-$PG_MAJOR \
24+
postgresql-common \
25+
&& apt-get clean \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
# Create vscode user with sudo access
29+
RUN groupadd --gid 1000 vscode \
30+
&& useradd --uid 1000 --gid 1000 -m -s /bin/bash vscode \
31+
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/vscode \
32+
&& chmod 0440 /etc/sudoers.d/vscode \
33+
&& chown -R vscode:vscode /usr/share/postgresql /usr/lib/postgresql
34+
35+
# Switch to vscode user
36+
USER vscode
37+
WORKDIR /home/vscode
38+
39+
# Set up Rust environment for vscode user
40+
ENV RUSTUP_HOME=/home/vscode/.rustup
41+
ENV CARGO_HOME=/home/vscode/.cargo
42+
ENV PATH="/home/vscode/.cargo/bin:/usr/lib/postgresql/$PG_MAJOR/bin:${PATH}"
43+
44+
# Install Rust
45+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable \
46+
&& . "$CARGO_HOME/env" \
47+
&& rustup component add clippy rustfmt rust-src
48+
49+
# Install cargo-pgrx
2950
ENV CARGO_PGRX_VERSION=0.16.1
30-
ENV PATH="/root/.cargo/bin:${PATH}"
51+
RUN . "$CARGO_HOME/env" \
52+
&& cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}"
3153

32-
RUN . $HOME/.cargo/env \
33-
&& rustup component add clippy rustfmt rust-src \
34-
&& cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}" \
54+
# Initialize pgrx
55+
RUN . "$CARGO_HOME/env" \
3556
&& cargo pgrx init --pg$PG_MAJOR $(which pg_config)
57+

.devcontainer/devcontainer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
},
66
"features": {
77
"ghcr.io/devcontainers/features/common-utils:2": {},
8-
"git": "latest"
8+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
9+
"ghcr.io/devcontainers/features/git:1": {},
10+
"ghcr.io/devcontainers/features/github-cli:1": {}
911
},
1012
"customizations": {
1113
"vscode": {
@@ -14,13 +16,13 @@
1416
},
1517
"extensions": [
1618
"rust-lang.rust-analyzer",
17-
"serayuzgur.crates"
19+
"fill-labs.dependi",
20+
"mk12.better-git-line-blame"
1821
]
1922
}
2023
},
24+
"remoteUser": "vscode",
2125
"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"
26+
"source=cargo-registry,target=/usr/local/cargo/registry,type=volume"
2527
]
2628
}

0 commit comments

Comments
 (0)