mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-22 21:59:59 +00:00
Avoid redownloading rust toolchain on Postgres changes (#12265)
Create a separate stage for downloading the Rust toolchain for pgrx, so that it can be cached independently of the pg-build layer. Before this, the 'pg-build-nonroot=with-cargo' layer was unnecessarily rebuilt every time there was a change in PostgreSQL sources. Furthermore, this allows using the same cached layer for building the compute images of all Postgres versions.
This commit is contained in:
committed by
GitHub
parent
04013929cb
commit
3af6b3a2bf
@@ -149,8 +149,10 @@ RUN case $DEBIAN_VERSION in \
|
|||||||
ninja-build git autoconf automake libtool build-essential bison flex libreadline-dev \
|
ninja-build git autoconf automake libtool build-essential bison flex libreadline-dev \
|
||||||
zlib1g-dev libxml2-dev libcurl4-openssl-dev libossp-uuid-dev wget ca-certificates pkg-config libssl-dev \
|
zlib1g-dev libxml2-dev libcurl4-openssl-dev libossp-uuid-dev wget ca-certificates pkg-config libssl-dev \
|
||||||
libicu-dev libxslt1-dev liblz4-dev libzstd-dev zstd curl unzip g++ \
|
libicu-dev libxslt1-dev liblz4-dev libzstd-dev zstd curl unzip g++ \
|
||||||
|
libclang-dev \
|
||||||
$VERSION_INSTALLS \
|
$VERSION_INSTALLS \
|
||||||
&& apt clean && rm -rf /var/lib/apt/lists/*
|
&& apt clean && rm -rf /var/lib/apt/lists/* && \
|
||||||
|
useradd -ms /bin/bash nonroot -b /home
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
@@ -1057,17 +1059,10 @@ RUN make -j $(getconf _NPROCESSORS_ONLN) && \
|
|||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
# Layer "pg build with nonroot user and cargo installed"
|
# Layer "build-deps with Rust toolchain installed"
|
||||||
# This layer is base and common for layers with `pgrx`
|
|
||||||
#
|
#
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
FROM pg-build AS pg-build-nonroot-with-cargo
|
FROM build-deps AS build-deps-with-cargo
|
||||||
ARG PG_VERSION
|
|
||||||
|
|
||||||
RUN apt update && \
|
|
||||||
apt install --no-install-recommends --no-install-suggests -y curl libclang-dev && \
|
|
||||||
apt clean && rm -rf /var/lib/apt/lists/* && \
|
|
||||||
useradd -ms /bin/bash nonroot -b /home
|
|
||||||
|
|
||||||
ENV HOME=/home/nonroot
|
ENV HOME=/home/nonroot
|
||||||
ENV PATH="/home/nonroot/.cargo/bin:$PATH"
|
ENV PATH="/home/nonroot/.cargo/bin:$PATH"
|
||||||
@@ -1082,13 +1077,29 @@ RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux
|
|||||||
./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
|
./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
|
||||||
rm rustup-init
|
rm rustup-init
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
#
|
||||||
|
# Layer "pg-build with Rust toolchain installed"
|
||||||
|
# This layer is base and common for layers with `pgrx`
|
||||||
|
#
|
||||||
|
#########################################################################################
|
||||||
|
FROM pg-build AS pg-build-with-cargo
|
||||||
|
ARG PG_VERSION
|
||||||
|
|
||||||
|
ENV HOME=/home/nonroot
|
||||||
|
ENV PATH="/home/nonroot/.cargo/bin:$PATH"
|
||||||
|
USER nonroot
|
||||||
|
WORKDIR /home/nonroot
|
||||||
|
|
||||||
|
COPY --from=build-deps-with-cargo /home/nonroot /home/nonroot
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
#
|
#
|
||||||
# Layer "rust extensions"
|
# Layer "rust extensions"
|
||||||
# This layer is used to build `pgrx` deps
|
# This layer is used to build `pgrx` deps
|
||||||
#
|
#
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
FROM pg-build-nonroot-with-cargo AS rust-extensions-build
|
FROM pg-build-with-cargo AS rust-extensions-build
|
||||||
ARG PG_VERSION
|
ARG PG_VERSION
|
||||||
|
|
||||||
RUN case "${PG_VERSION:?}" in \
|
RUN case "${PG_VERSION:?}" in \
|
||||||
@@ -1110,7 +1121,7 @@ USER root
|
|||||||
# and eventually get merged with `rust-extensions-build`
|
# and eventually get merged with `rust-extensions-build`
|
||||||
#
|
#
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
FROM pg-build-nonroot-with-cargo AS rust-extensions-build-pgrx12
|
FROM pg-build-with-cargo AS rust-extensions-build-pgrx12
|
||||||
ARG PG_VERSION
|
ARG PG_VERSION
|
||||||
|
|
||||||
RUN cargo install --locked --version 0.12.9 cargo-pgrx && \
|
RUN cargo install --locked --version 0.12.9 cargo-pgrx && \
|
||||||
@@ -1127,7 +1138,7 @@ USER root
|
|||||||
# and eventually get merged with `rust-extensions-build`
|
# and eventually get merged with `rust-extensions-build`
|
||||||
#
|
#
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
FROM pg-build-nonroot-with-cargo AS rust-extensions-build-pgrx14
|
FROM pg-build-with-cargo AS rust-extensions-build-pgrx14
|
||||||
ARG PG_VERSION
|
ARG PG_VERSION
|
||||||
|
|
||||||
RUN cargo install --locked --version 0.14.1 cargo-pgrx && \
|
RUN cargo install --locked --version 0.14.1 cargo-pgrx && \
|
||||||
|
|||||||
Reference in New Issue
Block a user