Skip to content

Commit 4f4983a

Browse files
committed
Add so files from the specified version to the test image
1 parent 24bb0ba commit 4f4983a

3 files changed

Lines changed: 107 additions & 3 deletions

File tree

circleci/images/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ CITUS_UPGRADE_VERSIONS_17=v13.2.0
2828
# Function to get Citus versions for a specific PG major version
2929
get_citus_versions = $(CITUS_UPGRADE_VERSIONS_$(1))
3030

31+
# Function to get the last Citus version for a specific PG major version
32+
get_last_citus_version = $(lastword $(CITUS_UPGRADE_VERSIONS_$(1)))
33+
3134
# code below creates targets for all postgres versions in PG_VERSIONS
3235
define make-image-targets
3336
# $1 = PG_VERSION
@@ -54,12 +57,12 @@ push-all:: push-extbuilder-$1
5457
push-extbuilder-all:: push-extbuilder-$1
5558

5659
build-exttester-$1:
57-
docker build \
58-
exttester/ \
60+
docker build . \
5961
-f exttester/Dockerfile \
6062
--build-arg=PG_VERSION=$1 \
6163
--build-arg=PG_MAJOR=$2 \
6264
--build-arg=PG_VERSION_CLEAN=$3 \
65+
--build-arg=CITUS_VERSION="$(call get_last_citus_version,$2)" \
6366
--tag=${DOCKER_REPO}/exttester:$3${TAG_SUFFIX}
6467

6568
build-all:: build-exttester-$1

circleci/images/citusupgradetester/files/sbin/build-citus

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ build_ext() {
5050

5151
cd "${installdir}" && find . -type f -print > "${builddir}/files.lst"
5252
tar cvf "${basedir}/install-pg${pg_major}-citus${citus_version}.tar" `cat ${builddir}/files.lst`
53-
53+
find usr/lib/postgresql/${pg_major}/lib -type f -name '*.so' -printf '%P\n' > "${builddir}/so-files.lst"
54+
tar cvf "${basedir}/so-pg${pg_major}-citus${citus_version}.tar" -C usr/lib/postgresql/${pg_major}/lib -T "${builddir}/so-files.lst"
5455
cd "${builddir}" && rm -rf install files.lst && make clean
5556
}
5657
for citus_version in ${CITUS_VERSIONS}

circleci/images/exttester/Dockerfile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,96 @@ COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/build/src/te
8484
COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/src/test/regress/ usr/lib/postgresql/${PG_MAJOR}/lib/regress/
8585
RUN 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+
87177
FROM buildpack-deps:bullseye
88178

89179
# add unpriviliged user for tests
@@ -183,4 +273,14 @@ RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgres
183273
# copy the collected files from the collection container at once into the final container
184274
COPY --from=dev-tools-collection /collect/ /
185275

276+
ARG CITUS_VERSION
277+
ENV CITUS_VERSION=$CITUS_VERSION
278+
279+
# copy citus so files from the build-citus stage
280+
WORKDIR /opt/citus-versions/${CITUS_VERSION}
281+
COPY --from=build-citus /build-citus/so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar .
282+
RUN tar xvf so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar
283+
# cleanup build artifacts
284+
RUN rm so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar
285+
186286
WORKDIR /home/circleci

0 commit comments

Comments
 (0)