pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.42k stars 223 forks source link

vscode, devcontainers and docker #1734

Open rosssaunders opened 3 weeks ago

rosssaunders commented 3 weeks ago

Hi,

Does anyone have a working example of developing pgrx based extensions within a docker devcontrainer in vscode?

With the following Docker file


RUN apt-get update && \
    apt-get install -y \
    git \
    curl \
    libclang-dev \
    gcc \
    build-essential \
    libreadline-dev \
    zlib1g-dev \
    flex \
    bison \
    libxml2-dev \
    libxslt-dev \
    libssl-dev \
    libxml2-utils \
    xsltproc \
    ccache \
    pkg-config

# Create a non-root user `developer` and setup sudo
RUN useradd -m -d /home/developer -s /bin/bash developer && \
    echo 'developer ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create /workspaces folder and give all permissions to the developer account
RUN mkdir /workspaces && chown -R developer:developer /workspaces

# Set the user to developer
USER developer
WORKDIR /home/developer

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Ensure cargo binaries are in PATH
ENV PATH=/home/developer/.cargo/bin:$PATH

# Install pgrx
RUN cargo install cargo-pgrx

and then installing the "rust-analyser" extension, it fails with the following compilation error in the output

  [shim for PG v16] /----------------------------------------

  Error: failed to make pgrx-cshim for v16

  Location:
      /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4/build.rs:889:20

I must be missing something simple but cannot track down what.

Thanks in advance,

Ross