Skip to content

Commit 1284f0b

Browse files
fedordikarevwinter-loo
authored andcommitted
unify pg-build-nonroot-with-cargo base layer and config retries in curl (neondatabase#10575)
Ref: https://github.com/neondatabase/cloud/issues/23461 ## Problem Just made changes around and see these 2 base layers could be optimised. and after review comment from @myrrc setting up timeouts and retries in `alpine/curl` image ## Summary of changes
1 parent b5efd4f commit 1284f0b

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

compute/compute-node.Dockerfile

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,11 @@ RUN case "${PG_VERSION}" in "v17") \
825825

826826
#########################################################################################
827827
#
828-
# Layer "rust extensions"
829-
# This layer is used to build `pgrx` deps
828+
# Layer "pg build with nonroot user and cargo installed"
829+
# This layer is base and common for layers with `pgrx`
830830
#
831831
#########################################################################################
832-
FROM pg-build AS rust-extensions-build
832+
FROM pg-build AS pg-build-nonroot-with-cargo
833833
ARG PG_VERSION
834834

835835
RUN apt update && \
@@ -847,8 +847,18 @@ RUN echo -e "--retry-connrefused\n--connect-timeout 15\n--retry 5\n--max-time 30
847847
RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init && \
848848
chmod +x rustup-init && \
849849
./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
850-
rm rustup-init && \
851-
case "${PG_VERSION}" in \
850+
rm rustup-init
851+
852+
#########################################################################################
853+
#
854+
# Layer "rust extensions"
855+
# This layer is used to build `pgrx` deps
856+
#
857+
#########################################################################################
858+
FROM pg-build-nonroot-with-cargo AS rust-extensions-build
859+
ARG PG_VERSION
860+
861+
RUN case "${PG_VERSION}" in \
852862
'v17') \
853863
echo 'v17 is not supported yet by pgrx. Quit' && exit 0;; \
854864
esac && \
@@ -867,26 +877,10 @@ USER root
867877
# and eventually get merged with `rust-extensions-build`
868878
#
869879
#########################################################################################
870-
FROM pg-build AS rust-extensions-build-pgrx12
880+
FROM pg-build-nonroot-with-cargo AS rust-extensions-build-pgrx12
871881
ARG PG_VERSION
872882

873-
RUN apt update && \
874-
apt install --no-install-recommends --no-install-suggests -y curl libclang-dev && \
875-
apt clean && rm -rf /var/lib/apt/lists/* && \
876-
useradd -ms /bin/bash nonroot -b /home
877-
878-
ENV HOME=/home/nonroot
879-
ENV PATH="/home/nonroot/.cargo/bin:$PATH"
880-
USER nonroot
881-
WORKDIR /home/nonroot
882-
883-
RUN echo -e "--retry-connrefused\n--connect-timeout 15\n--retry 5\n--max-time 300\n" > /home/nonroot/.curlrc
884-
885-
RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init && \
886-
chmod +x rustup-init && \
887-
./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
888-
rm rustup-init && \
889-
cargo install --locked --version 0.12.9 cargo-pgrx && \
883+
RUN cargo install --locked --version 0.12.9 cargo-pgrx && \
890884
/bin/bash -c 'cargo pgrx init --pg${PG_VERSION:1}=/usr/local/pgsql/bin/pg_config'
891885

892886
USER root
@@ -1283,7 +1277,8 @@ FROM alpine/curl:${ALPINE_CURL_VERSION} AS exporters
12831277
ARG TARGETARCH
12841278
# Keep sql_exporter version same as in build-tools.Dockerfile and
12851279
# test_runner/regress/test_compute_metrics.py
1286-
RUN if [ "$TARGETARCH" = "amd64" ]; then\
1280+
RUN echo -e "--retry-connrefused\n--connect-timeout 15\n--retry 5\n--max-time 300\n" > /root/.curlrc; \
1281+
if [ "$TARGETARCH" = "amd64" ]; then\
12871282
postgres_exporter_sha256='027e75dda7af621237ff8f5ac66b78a40b0093595f06768612b92b1374bd3105';\
12881283
pgbouncer_exporter_sha256='c9f7cf8dcff44f0472057e9bf52613d93f3ffbc381ad7547a959daa63c5e84ac';\
12891284
sql_exporter_sha256='38e439732bbf6e28ca4a94d7bc3686d3fa1abdb0050773d5617a9efdb9e64d08';\

0 commit comments

Comments
 (0)