1- FROM ubuntu:22.04
1+ ARG BASE_IMAGE_OS=almalinux
2+ ARG BASE_IMAGE_OS_VERSION=9
3+ FROM ${BASE_IMAGE_OS}:${BASE_IMAGE_OS_VERSION}
4+ ARG BASE_IMAGE_OS
5+ ARG BASE_IMAGE_OS_VERSION
26
37ENV DEBIAN_FRONTEND="noninteractive"
48ENV TZ="Europe/Istanbul"
59
6- ARG PG_MAJOR=18
10+ ARG DEFAULT_PG_MAJOR=18
11+
12+ SHELL ["/bin/bash" , "-c" ]
713
814# install deps
9- RUN apt-get update && apt-get -y install build-essential libreadline-dev zlib1g-dev \
10- flex bison libxml2-dev libxslt-dev libssl-dev \
11- libxml2-utils xsltproc ccache pkg-config wget \
12- curl lsb-release ca-certificates gnupg sudo git \
13- nano net-tools awscli libkrb5-dev
15+ RUN if [ "${BASE_IMAGE_OS}" = "debian" ]; then \
16+ apt-get update && apt-get -y install build-essential libreadline-dev zlib1g-dev \
17+ flex bison libxml2-dev libxslt-dev libssl-dev \
18+ libxml2-utils xsltproc ccache pkg-config wget \
19+ curl lsb-release ca-certificates gnupg sudo git \
20+ nano net-tools awscli libkrb5-dev python3.11 pip; \
21+ fi
22+ RUN if [ "${BASE_IMAGE_OS}" = "almalinux" ]; then \
23+ dnf -y update && \
24+ dnf -y install epel-release && \
25+ dnf config-manager --enable crb && \
26+ dnf -y install gcc gcc-c++ make readline-devel zlib-devel which \
27+ flex bison libxml2-devel libxslt-devel openssl-devel \
28+ ccache pkgconfig wget lsb_release ca-certificates \
29+ gnupg sudo git nano net-tools awscli krb5-devel \
30+ python3.11 pip; \
31+ fi
32+
33+ # Upgrade pip and uv
34+ RUN if [ "$BASE_IMAGE_OS" = "almalinux" ]; then \
35+ python3.11 -m ensurepip --upgrade && \
36+ python3.11 -m pip install --upgrade pip && \
37+ python3.11 -m pip install uv; \
38+ fi
39+ RUN if [ "$BASE_IMAGE_OS" = "debian" ]; then \
40+ python3.11 -m pip install --upgrade pip --break-system-packages && \
41+ python3.11 -m pip install uv --break-system-packages; \
42+ fi
43+
44+ ENV PATH="~/.local/bin:$PATH"
45+
46+ # Install uv (we run mitmproxy with it)
47+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
1448
1549# install azure-cli
16- RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/keyrings/microsoft.gpg > /dev/null
17- RUN echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ `lsb_release -cs` main" | tee /etc/apt/sources.list.d/azure-cli.list
18- RUN apt-get update && apt-get install -y azure-cli
50+ RUN if [ "${BASE_IMAGE_OS}" = "debian" ]; then \
51+ curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/keyrings/microsoft.gpg > /dev/null && \
52+ echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ `lsb_release -cs` main" | tee /etc/apt/sources.list.d/azure-cli.list && \
53+ apt-get update && apt-get install -y azure-cli; \
54+ fi
55+ RUN if [ "${BASE_IMAGE_OS}" = "almalinux" ]; then \
56+ rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
57+ dnf install -y https://packages.microsoft.com/config/rhel/${BASE_IMAGE_OS_VERSION}/packages-microsoft-prod.rpm && \
58+ dnf install -y azure-cli; \
59+ fi
1960
2061# install Postgres
21- RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
22- RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
23- RUN apt-get update && apt-get -y install postgresql-${PG_MAJOR}-postgis-3 \
24- postgresql-server-dev-${PG_MAJOR} \
25- postgresql-client-${PG_MAJOR} \
26- libpq-dev
62+ RUN if [ "${BASE_IMAGE_OS}" = "debian" ]; then \
63+ sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
64+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
65+ apt-get update && apt-get -y install postgresql-{14,15,16,17,18}-postgis-3 \
66+ postgresql-{14,15,16,17,18}-pgaudit \
67+ postgresql-server-dev-{14,15,16,17,18} \
68+ postgresql-client-{14,15,16,17,18} \
69+ libpq-dev; \
70+ fi
71+ RUN if [ "${BASE_IMAGE_OS}" = "almalinux" ]; then \
72+ ARCH=$(uname -m) && \
73+ dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-${ARCH}/pgdg-redhat-repo-latest.noarch.rpm && \
74+ dnf -qy module disable postgresql && \
75+ dnf install -y --nogpgcheck \
76+ postgis36_{14,15,16,17,18} \
77+ pgaudit{16_14,17_15,_16,_17,_18} \
78+ postgresql{14,15,16,17,18}-libs \
79+ postgresql{14,15,16,17,18}-devel; \
80+ fi
81+
82+ # default pg version for debian
83+ ENV PATH="/usr/lib/postgresql/${DEFAULT_PG_MAJOR}/bin:${PATH}"
84+
85+ # default pg version for almalinux
86+ ENV PATH="/usr/pgsql-${DEFAULT_PG_MAJOR}/bin/:${PATH}"
2787
2888# set up permissions so that rust user can create extensions
29- RUN chmod a+rwx `pg_config --pkglibdir` \
30- `pg_config --pkglibdir`/bitcode \
31- `pg_config --sharedir`/extension \
32- /var/run/postgresql/
33-
34- # install pgaudit extension
35- RUN if [ ${PG_MAJOR} != "18" ]; then \
36- apt-get -y install postgresql-${PG_MAJOR}-pgaudit; \
37- else \
38- git clone --branch integration https://github.com/pgaudit/pgaudit.git /tmp/pgaudit && \
39- cd /tmp/pgaudit && make install USE_PGXS=1 PG_CONFIG=pg_config; \
89+ RUN if [ "${BASE_IMAGE_OS}" = "debian" ]; then \
90+ chmod a+rwx `/usr/lib/postgresql/14/bin/pg_config --pkglibdir` \
91+ `/usr/lib/postgresql/14/bin/pg_config --pkglibdir`/bitcode \
92+ `/usr/lib/postgresql/14/bin/pg_config --sharedir`/extension \
93+ /var/run/postgresql/ && \
94+ chmod a+rwx `/usr/lib/postgresql/15/bin/pg_config --pkglibdir` \
95+ `/usr/lib/postgresql/15/bin/pg_config --pkglibdir`/bitcode \
96+ `/usr/lib/postgresql/15/bin/pg_config --sharedir`/extension \
97+ /var/run/postgresql/ && \
98+ chmod a+rwx `/usr/lib/postgresql/16/bin/pg_config --pkglibdir` \
99+ `/usr/lib/postgresql/16/bin/pg_config --pkglibdir`/bitcode \
100+ `/usr/lib/postgresql/16/bin/pg_config --sharedir`/extension \
101+ /var/run/postgresql/ && \
102+ chmod a+rwx `/usr/lib/postgresql/17/bin/pg_config --pkglibdir` \
103+ `/usr/lib/postgresql/17/bin/pg_config --pkglibdir`/bitcode \
104+ `/usr/lib/postgresql/17/bin/pg_config --sharedir`/extension \
105+ /var/run/postgresql/ && \
106+ chmod a+rwx `/usr/lib/postgresql/18/bin/pg_config --pkglibdir` \
107+ `/usr/lib/postgresql/18/bin/pg_config --pkglibdir`/bitcode \
108+ `/usr/lib/postgresql/18/bin/pg_config --sharedir`/extension \
109+ /var/run/postgresql/; \
110+ fi
111+ RUN if [ "${BASE_IMAGE_OS}" = "almalinux" ]; then \
112+ chmod a+rwx `/usr/pgsql-14/bin/pg_config --pkglibdir` \
113+ `/usr/pgsql-14/bin/pg_config --pkglibdir`/bitcode \
114+ `/usr/pgsql-14/bin/pg_config --sharedir`/extension \
115+ /var/run/postgresql/ && \
116+ chmod a+rwx `/usr/pgsql-15/bin/pg_config --pkglibdir` \
117+ `/usr/pgsql-15/bin/pg_config --pkglibdir`/bitcode \
118+ `/usr/pgsql-15/bin/pg_config --sharedir`/extension \
119+ /var/run/postgresql/ && \
120+ chmod a+rwx `/usr/pgsql-16/bin/pg_config --pkglibdir` \
121+ `/usr/pgsql-16/bin/pg_config --pkglibdir`/bitcode \
122+ `/usr/pgsql-16/bin/pg_config --sharedir`/extension \
123+ /var/run/postgresql/ && \
124+ chmod a+rwx `/usr/pgsql-17/bin/pg_config --pkglibdir` \
125+ `/usr/pgsql-17/bin/pg_config --pkglibdir`/bitcode \
126+ `/usr/pgsql-17/bin/pg_config --sharedir`/extension \
127+ /var/run/postgresql/ && \
128+ chmod a+rwx `/usr/pgsql-18/bin/pg_config --pkglibdir` \
129+ `/usr/pgsql-18/bin/pg_config --pkglibdir`/bitcode \
130+ `/usr/pgsql-18/bin/pg_config --sharedir`/extension \
131+ /var/run/postgresql/; \
40132 fi
41133
42134# initdb requires non-root user. This will also be the user that runs the container.
43135ARG USERNAME=rust
44- ARG USER_UID=1000
45- ARG USER_GID=1000
136+ ARG USER_UID=1001
137+ ARG USER_GID=1001
46138RUN groupadd --gid $USER_GID $USERNAME
47139RUN useradd --uid $USER_UID --gid $USER_GID -s /bin/bash -m $USERNAME
48140
@@ -51,14 +143,45 @@ RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME
51143USER $USERNAME
52144
53145# install Rust environment
146+ ARG RUSTC_VERSION=1.90.0
54147RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
148+
55149ENV PATH="/home/rust/.cargo/bin:${PATH}"
56150
151+ RUN rustup install ${RUSTC_VERSION} && \
152+ rustup default ${RUSTC_VERSION} && \
153+ rustup component add rustfmt clippy llvm-tools-preview
154+
155+ # install llvm-cov for coverage reports
156+ RUN cargo install --locked
[email protected] 157+
57158# install and configure pgrx
58159ARG PGRX_VERSION=0.16.1
59160RUN cargo install --locked cargo-pgrx@${PGRX_VERSION}
60- RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config)
61- RUN echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-${PG_MAJOR}/postgresql.conf
161+
162+ ENV PGRX_TEST_PG_BASE_PORT=5454
163+ RUN if [ "${BASE_IMAGE_OS}" = "debian" ]; then \
164+ cargo pgrx init --pg14 /usr/lib/postgresql/14/bin/pg_config \
165+ --pg15 /usr/lib/postgresql/15/bin/pg_config \
166+ --pg16 /usr/lib/postgresql/16/bin/pg_config \
167+ --pg17 /usr/lib/postgresql/17/bin/pg_config \
168+ --pg18 /usr/lib/postgresql/18/bin/pg_config \
169+ --base-testing-port ${PGRX_TEST_PG_BASE_PORT}; \
170+ fi
171+ RUN if [ "${BASE_IMAGE_OS}" = "almalinux" ]; then \
172+ cargo pgrx init --pg14 /usr/pgsql-14/bin/pg_config \
173+ --pg15 /usr/pgsql-15/bin/pg_config \
174+ --pg16 /usr/pgsql-16/bin/pg_config \
175+ --pg17 /usr/pgsql-17/bin/pg_config \
176+ --pg18 /usr/pgsql-18/bin/pg_config \
177+ --base-testing-port ${PGRX_TEST_PG_BASE_PORT}; \
178+ fi
179+
180+ RUN echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-14/postgresql.conf && \
181+ echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-15/postgresql.conf && \
182+ echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-16/postgresql.conf && \
183+ echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-17/postgresql.conf && \
184+ echo "shared_preload_libraries = 'pgaudit,pg_parquet'" >> $HOME/.pgrx/data-18/postgresql.conf
62185
63186# required for pgrx to work
64187ENV USER=$USERNAME
0 commit comments