update devcontainter to use upstream+switch pgenv

pull/7102/head
Nils Dijk 2022-05-05 17:02:30 +02:00
parent 210d68e9d7
commit 03eb55bf0a
4 changed files with 58 additions and 33 deletions

View File

@ -1,9 +1,11 @@
FROM ubuntu:20.04 AS base FROM ubuntu:22.04 AS base
# environment is to make python pass an interactive shell, probably not the best timezone given a wide variety of colleagues # environment is to make python pass an interactive shell, probably not the best timezone given a wide variety of colleagues
ENV TZ=Europe/Amsterdam ENV TZ=Europe/Amsterdam
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN yes | unminimize
RUN apt update && apt install -y \ RUN apt update && apt install -y \
autoconf \ autoconf \
bzip2 \ bzip2 \
@ -27,10 +29,13 @@ RUN apt update && apt install -y \
libzstd-dev \ libzstd-dev \
locales \ locales \
make \ make \
man\
pkg-config \
pspg \ pspg \
python3 \ python3 \
python3-pip \ python3-pip \
sudo \ sudo \
# TODO install specific version of uncrustify
uncrustify \ uncrustify \
uuid-dev \ uuid-dev \
vim \ vim \
@ -48,44 +53,59 @@ RUN usermod -aG sudo citus
WORKDIR /home/citus WORKDIR /home/citus
USER citus USER citus
RUN git clone --branch feature/configure https://github.com/thanodnl/pgenv.git .pgenv RUN git clone --branch feature/switch https://github.com/thanodnl/pgenv.git .pgenv
COPY --chown=citus:citus pgenv/config/ .pgenv/config/
ENV PATH="/home/citus/.pgenv/bin:${PATH}" ENV PATH="/home/citus/.pgenv/bin:${PATH}"
ENV PATH="/home/citus/.pgenv/pgsql/bin:${PATH}" ENV PATH="/home/citus/.pgenv/pgsql/bin:${PATH}"
COPY --chown=citus:citus configure.flags .pgenv/
# COPY --chown=citus:citus *.tar.bz2 .pgenv/src/
USER citus USER citus
# build postgres versions separately for effective parrallelism and caching of already built versions when changing only certain versions # build postgres versions separately for effective parrallelism and caching of already built versions when changing only certain versions
FROM base AS pg12 FROM base AS pg12
RUN pgenv build 12.9 RUN pgenv build 12.10
RUN rm .pgenv/src/*.tar* RUN rm .pgenv/src/*.tar*
# TODO remove excessive artifacts for smaller images # TODO remove excessive artifacts for smaller images
RUN make -C .pgenv/src/postgresql-*/ clean RUN make -C .pgenv/src/postgresql-*/ clean
# create a staging directory with all files we want to copy from our pgenv build
# we will copy the contents of the staged folder into the final image at once
RUN mkdir .pgenv-staging/
RUN cp -r .pgenv/src .pgenv/pgsql-* .pgenv/config .pgenv-staging/
RUN rm .pgenv-staging/config/default.conf
RUN ls -alh .pgenv-staging/
FROM base AS pg13 FROM base AS pg13
RUN pgenv build 13.5 RUN pgenv build 13.6
RUN rm .pgenv/src/*.tar* RUN rm .pgenv/src/*.tar*
# TODO remove excessive artifacts for smaller images # TODO remove excessive artifacts for smaller images
RUN make -C .pgenv/src/postgresql-*/ clean RUN make -C .pgenv/src/postgresql-*/ clean
# create a staging directory with all files we want to copy from our pgenv build
# we will copy the contents of the staged folder into the final image at once
RUN mkdir .pgenv-staging/
RUN cp -r .pgenv/src .pgenv/pgsql-* .pgenv/config .pgenv-staging/
RUN rm .pgenv-staging/config/default.conf
RUN ls -alh .pgenv-staging/
FROM base AS pg14 FROM base AS pg14
RUN pgenv build 14.1 RUN pgenv build 14.2
RUN rm .pgenv/src/*.tar* RUN rm .pgenv/src/*.tar*
# TODO remove excessive artifacts for smaller images # TODO remove excessive artifacts for smaller images
RUN make -C .pgenv/src/postgresql-*/ clean RUN make -C .pgenv/src/postgresql-*/ clean
# create a staging directory with all files we want to copy from our pgenv build
# we will copy the contents of the staged folder into the final image at once
RUN mkdir .pgenv-staging/
RUN cp -r .pgenv/src .pgenv/pgsql-* .pgenv/config .pgenv-staging/
RUN rm .pgenv-staging/config/default.conf
RUN ls -alh .pgenv-staging/
# assemble the final container by copying over the artifacts from separately build containers # assemble the final container by copying over the artifacts from separately build containers
FROM base AS devcontainer FROM base AS devcontainer
COPY --from=pg12 /home/citus/.pgenv/src /home/citus/.pgenv/src
COPY --from=pg12 /home/citus/.pgenv/pgsql-12.9 /home/citus/.pgenv/pgsql-12.9
COPY --from=pg13 /home/citus/.pgenv/src /home/citus/.pgenv/src COPY --from=pg12 /home/citus/.pgenv-staging/ /home/citus/.pgenv/
COPY --from=pg13 /home/citus/.pgenv/pgsql-13.5 /home/citus/.pgenv/pgsql-13.5 COPY --from=pg13 /home/citus/.pgenv-staging/ /home/citus/.pgenv/
COPY --from=pg14 /home/citus/.pgenv-staging/ /home/citus/.pgenv/
COPY --from=pg14 /home/citus/.pgenv/src /home/citus/.pgenv/src
COPY --from=pg14 /home/citus/.pgenv/pgsql-14.1 /home/citus/.pgenv/pgsql-14.1
# add some common tools to the final container # add some common tools to the final container
# bin directory for user tools # bin directory for user tools
@ -93,21 +113,21 @@ RUN mkdir .bin
ENV PATH="/home/citus/.bin:${PATH}" ENV PATH="/home/citus/.bin:${PATH}"
# install citus-dev # install citus-dev
RUN git clone https://github.com/citusdata/tools.git citus-tools RUN git clone https://github.com/citusdata/tools.git citus-tools \
RUN pip3 install -r citus-tools/citus_dev/requirements.txt && pip3 install -r citus-tools/citus_dev/requirements.txt \
RUN ln -s /home/citus/citus-tools/citus_dev/citus_dev .bin/ && ln -s /home/citus/citus-tools/citus_dev/citus_dev .bin/ \
RUN sudo make -C citus-tools/uncrustify install bindir=/usr/local/bin pkgsysconfdir=/usr/local/etc/ && sudo make -C citus-tools/uncrustify install bindir=/usr/local/bin pkgsysconfdir=/usr/local/etc/
# TODO some LC_ALL errors, possibly solved by locale-gen # TODO some LC_ALL errors, possibly solved by locale-gen
RUN git clone https://github.com/so-fancy/diff-so-fancy.git RUN git clone https://github.com/so-fancy/diff-so-fancy.git \
RUN ln -s /home/citus/diff-so-fancy/diff-so-fancy .bin/ && ln -s /home/citus/diff-so-fancy/diff-so-fancy .bin/
# place to run your cluster with citus_dev # place to run your cluster with citus_dev
VOLUME /data VOLUME /data
RUN sudo mkdir /data RUN sudo mkdir /data \
RUN sudo chown citus:citus /data && sudo chown citus:citus /data
COPY --chown=citus:citus .psqlrc . COPY --chown=citus:citus .psqlrc .
# sets default pg version # sets default pg version
RUN pgenv switch 14.1 RUN pgenv switch latest 14

View File

@ -1,8 +0,0 @@
--enable-debug
--enable-depend
--enable-cassert
CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer
--with-libxml
--with-libxslt
--with-uuid=e2fs
--with-openssl

View File

@ -1,5 +1,5 @@
{ {
"image": "citus/devcontainer:dev-1", "image": "citus/devcontainer:dev-20220505",
"runArgs": [ "runArgs": [
"--cap-add=SYS_PTRACE", "--cap-add=SYS_PTRACE",
"--security-opt", "--security-opt",

View File

@ -0,0 +1,13 @@
PGENV_MAKE_OPTIONS=(-sj8)
PGENV_CONFIGURE_OPTIONS=(
--enable-debug
--enable-depend
--enable-cassert
'CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer'
--with-libxml
--with-libxslt
--with-uuid=e2fs
--with-openssl
--with-icu
)