From 93174e6793e3c7a9e5d677d8510cbfd4e73748ab Mon Sep 17 00:00:00 2001 From: Nils Dijk Date: Mon, 13 Sep 2021 17:39:07 +0200 Subject: [PATCH] initial setup for devcontianer --- .devcontainer/.gitignore | 1 + .devcontainer/.psqlrc | 7 +++ .devcontainer/Dockerfile | 87 +++++++++++++++++++++++++++++++++ .devcontainer/configure.flags | 8 +++ .devcontainer/devcontainer.json | 3 ++ 5 files changed, 106 insertions(+) create mode 100644 .devcontainer/.gitignore create mode 100644 .devcontainer/.psqlrc create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/configure.flags create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 000000000..3a7f553fc --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1 @@ +postgresql-*.tar.bz2 diff --git a/.devcontainer/.psqlrc b/.devcontainer/.psqlrc new file mode 100644 index 000000000..94d45e2fa --- /dev/null +++ b/.devcontainer/.psqlrc @@ -0,0 +1,7 @@ +\timing on +\pset linestyle unicode +\pset border 2 +\setenv PAGER 'pspg --no-mouse -bX --no-commandbar --no-topbar' +\set HISTSIZE 100000 +\set PROMPT1 '\n%[%033[1m%]%M %n@%/:%>-%p%R%[%033[0m%]%# ' +\set PROMPT2 ' ' diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..edce63520 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,87 @@ +FROM ubuntu:21.10 + +RUN apt update && apt install -y \ + autoconf \ + bzip2 \ + curl \ + flex \ + gcc \ + git \ + htop \ + libcurl4-gnutls-dev \ + libicu-dev \ + libkrb5-dev \ + liblz4-dev \ + liblz4-dev \ + libpam0g-dev \ + libreadline-dev \ + libreadline-dev \ + libselinux1-dev \ + libssl-dev \ + libxslt-dev \ + libzstd-dev \ + make \ + sudo \ + uuid-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* +# TODO remove caches with `apt clean` instead + +# allow all sudoers to login without a password prompt +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +RUN useradd -ms /bin/bash citus +RUN usermod -aG sudo citus + +WORKDIR /home/citus +USER citus + +RUN git clone --branch feature/configure https://github.com/thanodnl/pgenv.git .pgenv +ENV PATH="/home/citus/.pgenv/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 + +# TODO add more postgres versions +RUN pgenv build 13.4 + +# sets default pg version +RUN pgenv switch 13.4 + +# probably fold into install block earlier +#environment is to make python pass an interactive shell, probably not the best timezone given a wide variety of colleagues +ENV TZ=Europe/Amsterdam +RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ | sudo tee /etc/timezone + +RUN sudo apt update && sudo apt install -y \ + python3 \ + python3-pip \ + locales \ + && sudo apt clean + +RUN sudo locale-gen en_US.UTF-8 + +# bin directory for user tools +RUN mkdir .bin +ENV PATH="/home/citus/.bin:${PATH}" + +# install citus-dev +RUN git clone https://github.com/citusdata/tools.git citus-tools +RUN pip3 install -r citus-tools/citus_dev/requirements.txt +RUN ln -s /home/citus/citus-tools/citus_dev/citus_dev .bin/ + +# TODO add citus_indent + +# TODO some LC_ALL errors, possibly solved by locale-gen +RUN git clone https://github.com/so-fancy/diff-so-fancy.git +RUN ln -s /home/citus/diff-so-fancy/diff-so-fancy .bin/ + +# place to run your cluster with citus_dev +VOLUME /data +RUN sudo mkdir /data +RUN sudo chown citus:citus /data + +COPY --chown=citus:citus .psqlrc . diff --git a/.devcontainer/configure.flags b/.devcontainer/configure.flags new file mode 100644 index 000000000..645cae04b --- /dev/null +++ b/.devcontainer/configure.flags @@ -0,0 +1,8 @@ +--enable-debug +--enable-depend +--enable-cassert +CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer +--with-libxml +--with-libxslt +--with-uuid=e2fs +--with-openssl diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..2c734189d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,3 @@ +{ + "build": { "dockerfile": "Dockerfile" }, +} \ No newline at end of file