@@ -84,97 +84,7 @@ COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/build/src/te
8484COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/src/test/regress/ usr/lib/postgresql/${PG_MAJOR}/lib/regress/
8585RUN rm -rf usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.c usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.h
8686
87- FROM buildpack-deps:bullseye AS build-citus
88-
89- # add unpriviliged user for tests
90- RUN useradd -ms /bin/bash circleci
91-
92- RUN <<'EOF'
93- # install dependencies
94- set -eux
95- apt-get update
96-
97- apt-get install -y --no-install-recommends \
98- apt-transport-https \
99- autoconf \
100- build-essential \
101- ca-certificates \
102- curl \
103- debian-archive-keyring \
104- gcc \
105- gnupg \
106- gosu \
107- libcurl4 \
108- libcurl4-openssl-dev \
109- libicu-dev \
110- liblz4-1 \
111- liblz4-dev \
112- libreadline-dev \
113- libselinux1-dev \
114- libssl-dev \
115- libxslt-dev \
116- libzstd-dev \
117- libzstd1 \
118- locales \
119- make \
120- perl \
121-
122- # clear apt cache
123- rm -rf /var/lib/apt/lists/*
124- EOF
125-
126- ARG PG_VERSION
127- ARG PG_MAJOR
128- ENV PG_VERSION=$PG_VERSION
129- ENV PG_MAJOR=$PG_MAJOR
130-
131- RUN <<'EOF'
132- # install postgres ecosystem for pg version: $PG_VERSION
133- set -eux
134-
135- # install key and repositories
136- curl -sf https://www.postgresql.org/media/keys/ACCC4CF8.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add -
137- echo "deb https://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" >> /etc/apt/sources.list.d/postgresql.list
138- echo "deb https://apt-archive.postgresql.org/pub/repos/apt bullseye-pgdg-archive main" >> /etc/apt/sources.list.d/postgresql.list
139-
140- apt-get update
141-
142- # infer the pgdgversion of postgres based on the $PG_VERSION
143- pgdg_version=$(apt list -a postgresql-server-dev-${PG_MAJOR} 2>/dev/null | grep "${PG_VERSION}" | awk '{print $2}' | head -n1 )
144-
145- apt-get install -y --no-install-recommends --allow-downgrades \
146- libpq-dev=${pgdg_version} \
147- libpq5=${pgdg_version} \
148- postgresql-${PG_MAJOR}=${pgdg_version} \
149- postgresql-client-${PG_MAJOR}=${pgdg_version} \
150- postgresql-${PG_MAJOR}-dbgsym=${pgdg_version} \
151- postgresql-server-dev-${PG_MAJOR}=${pgdg_version}
152-
153- # clear apt cache
154- rm -rf /var/lib/apt/lists/*
155- EOF
156-
157- # add postgress to the path
158- ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin/:$PATH
159-
160- # setup /var/run/postgresql for use with circleci
161- RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
162-
163-
164- ARG CITUS_VERSION
165- ENV CITUS_VERSION=$CITUS_VERSION
166- ENV CITUS_VERSIONS=$CITUS_VERSION
167-
168- WORKDIR /build-citus/
169- COPY citusupgradetester/files/sbin/build-citus .
170- RUN ./build-citus
171-
172-
173- USER circleci
174- WORKDIR /home/circleci
175-
176-
177- FROM buildpack-deps:bullseye
87+ FROM buildpack-deps:bullseye AS setup-environment
17888
17989# add unpriviliged user for tests
18090RUN useradd -ms /bin/bash circleci
@@ -232,8 +142,10 @@ RUN locale-gen
232142
233143ARG PG_VERSION
234144ARG PG_MAJOR
145+ ARG CITUS_VERSION
235146ENV PG_VERSION=$PG_VERSION
236147ENV PG_MAJOR=$PG_MAJOR
148+ ENV CITUS_VERSION=$CITUS_VERSION
237149
238150RUN <<'EOF'
239151# install postgres ecosystem for pg version: $PG_VERSION
@@ -270,11 +182,27 @@ ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin/:$PATH
270182# setup /var/run/postgresql for use with circleci
271183RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
272184
273- # copy the collected files from the collection container at once into the final container
274- COPY --from=dev-tools-collection /collect/ /
185+
186+ FROM setup-environment AS build-citus
187+
188+ ENV CITUS_VERSIONS=$CITUS_VERSION
189+
190+ WORKDIR /build-citus/
191+ COPY citusupgradetester/files/sbin/build-citus .
192+ RUN ./build-citus
193+
194+
195+ FROM setup-environment
275196
276197ARG CITUS_VERSION
198+ ARG PG_VERSION
199+ ARG PG_MAJOR
277200ENV CITUS_VERSION=$CITUS_VERSION
201+ ENV PG_MAJOR=$PG_MAJOR
202+ ENV PG_VERSION=$PG_VERSION
203+
204+ # copy the collected files from the collection container at once into the final container
205+ COPY --from=dev-tools-collection /collect/ /
278206
279207# copy citus so files from the build-citus stage
280208WORKDIR /opt/citus-versions/${CITUS_VERSION}
0 commit comments