Skip to content
Merged
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
71 changes: 27 additions & 44 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,40 @@
FROM debian:bookworm-slim
FROM rust:1-bookworm

ENV DEBIAN_FRONTEND=noninteractive
ENV PG_MAJOR=17

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates curl gnupg apt-transport-https \
build-essential git pkg-config \
libreadline-dev zlib1g-dev flex bison \
libxml2-dev libxslt-dev libssl-dev \
libxml2-utils xsltproc ccache \
clang libclang-dev \
protobuf-compiler libprotobuf-dev \
sudo \
&& update-ca-certificates \
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-$PG_MAJOR \
postgresql-server-dev-$PG_MAJOR \
postgresql-common \
&& apt-get clean \
RUN apt-get update && apt-get install -y \
build-essential \
bison \
flex \
clang \
protobuf-compiler \
libreadline8 \
libreadline-dev \
git \
curl \
pkg-config \
libssl-dev \
sudo \
&& rm -rf /var/lib/apt/lists/*

# Create vscode user with sudo access
RUN groupadd --gid 1000 vscode \
&& useradd --uid 1000 --gid 1000 -m -s /bin/bash vscode \
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/vscode \
&& chmod 0440 /etc/sudoers.d/vscode \
&& chown -R vscode:vscode /usr/share/postgresql /usr/lib/postgresql
# Create a non-root user for running PostgreSQL
RUN useradd -m -s /bin/bash -u 1000 vscode && \
echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Switch to vscode user
# Switch to non-root user
USER vscode
WORKDIR /home/vscode

# Set up Rust environment for vscode user
ENV RUSTUP_HOME=/home/vscode/.rustup
ENV CARGO_HOME=/home/vscode/.cargo
ENV PATH="/home/vscode/.cargo/bin:/usr/lib/postgresql/$PG_MAJOR/bin:${PATH}"
# Set up Rust and cargo for vscode user
ENV PATH="/home/vscode/.cargo/bin:${PATH}"
ENV CARGO_HOME="/home/vscode/.cargo"

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable \
&& . "$CARGO_HOME/env" \
&& rustup component add clippy rustfmt rust-src

# Install cargo-pgrx
# Install pgrx as vscode user
ENV CARGO_PGRX_VERSION=0.16.1
RUN . "$CARGO_HOME/env" \
&& cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}"
RUN cargo install --force --locked cargo-pgrx@"${CARGO_PGRX_VERSION}"

# Initialize pgrx
RUN . "$CARGO_HOME/env" \
&& cargo pgrx init --pg$PG_MAJOR $(which pg_config)
# Set working directory
WORKDIR /workspace

# Keep container running
CMD ["sleep", "infinity"]
36 changes: 20 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
{
"name": "rust-dev",
"name": "etcd_fdw Development",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
"dockerfile": "Dockerfile",
"context": "."
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"rust-lang.rust-analyzer",
"fill-labs.dependi",
"tamasfe.even-better-toml",
"vadimcn.vscode-lldb",
"mk12.better-git-line-blame"
]
],
"settings": {
"rust-analyzer.cargo.features": "all",
"rust-analyzer.check.command": "clippy"
}
}
},
"remoteUser": "vscode",
"mounts": [
"source=cargo-registry,target=/usr/local/cargo/registry,type=volume"
]
"source=etcd-fdw-cargo-cache,target=/home/vscode/.cargo/registry,type=volume"
],
"postCreateCommand": "cargo pgrx init --pg17 download && cargo build",
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
}
}
Loading