Skip to content

Commit 9f56243

Browse files
committed
debian and almalinux images
1 parent 44f7eb8 commit 9f56243

File tree

20 files changed

+668
-1335
lines changed

20 files changed

+668
-1335
lines changed

.devcontainer/.env

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
AWS_ACCESS_KEY_ID=minioadmin
33
AWS_SECRET_ACCESS_KEY=minioadmin
44
AWS_REGION=us-east-1
5-
AWS_ENDPOINT_URL=http://localhost:9000
5+
AWS_ENDPOINT_URL=http://minio:9000
66
AWS_ENDPOINT_PROXY_PORT=9999
77
AWS_ALLOW_HTTP=true
88
AWS_S3_TEST_BUCKET=testbucket
@@ -12,24 +12,44 @@ MINIO_ROOT_PASSWORD=minioadmin
1212
# Azure Blob tests
1313
AZURE_STORAGE_ACCOUNT=devstoreaccount1
1414
AZURE_STORAGE_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
15-
AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;"
16-
AZURE_STORAGE_ENDPOINT=http://localhost:10000/devstoreaccount1
15+
AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;"
16+
AZURE_STORAGE_ENDPOINT=http://azurite:10000/devstoreaccount1
1717
AZURE_ALLOW_HTTP=true
1818
AZURE_TEST_CONTAINER_NAME=testcontainer
1919
AZURE_TEST_READ_ONLY_SAS=se=2100-05-05&sp=r&sv=2022-11-02&sr=c&sig=YMPFnAHKe9y0o3hFegncbwQTXtAyvsJEgPB2Ne1b9CQ%3D
2020
AZURE_TEST_READ_WRITE_SAS=se=2100-05-05&sp=rcw&sv=2022-11-02&sr=c&sig=TPz2jEz0t9L651t6rTCQr%2BOjmJHkM76tnCGdcyttnlA%3D
2121

2222
# http(s) tests
2323
ALLOW_HTTP=true
24-
HTTP_ENDPOINT=http://localhost:8080
24+
HTTP_ENDPOINT=http://webdav:8080
2525

2626
# GCS tests
2727
GOOGLE_TEST_BUCKET=testbucket
28-
GOOGLE_SERVICE_ACCOUNT_KEY={"gcs_base_url":"http://localhost:4443","disable_oauth":true,"client_email":"","private_key_id":"","private_key":""}
29-
GOOGLE_SERVICE_ENDPOINT=http://localhost:4443
28+
GOOGLE_SERVICE_ACCOUNT_KEY={"gcs_base_url":"http://fake-gcs-server:4443","disable_oauth":true,"client_email":"","private_key_id":"","private_key":""}
29+
GOOGLE_SERVICE_ENDPOINT=http://fake-gcs-server:4443
3030

3131
# Others
32+
3233
# run pgrx tests with a single thread to avoid race conditions
3334
RUST_TEST_THREADS=1
35+
3436
# pgrx runs test on the port base_port + pg_version
3537
PGRX_TEST_PG_BASE_PORT=5454
38+
39+
# default PostgreSQL version
40+
DEFAULT_PG_MAJOR=18
41+
42+
# Rust version
43+
RUSTC_VERSION=1.90.0
44+
45+
# rust build flags
46+
RUST_BACKTRACE=1
47+
CARGO_INCREMENTAL=0
48+
49+
# Docker images
50+
MINIO_IMAGE=docker.io/minio/minio
51+
AZURITE_IMAGE=mcr.microsoft.com/azure-storage/azurite
52+
FAKE_GCS_IMAGE=docker.io/tustvold/fake-gcs-server
53+
WEBDAV_IMAGE=docker.io/rclone/rclone
54+
BASE_IMAGE_OS=almalinux
55+
BASE_IMAGE_TAG=9

.devcontainer/Dockerfile

Lines changed: 154 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,140 @@
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

37
ENV DEBIAN_FRONTEND="noninteractive"
48
ENV 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.
43135
ARG USERNAME=rust
44-
ARG USER_UID=1000
45-
ARG USER_GID=1000
136+
ARG USER_UID=1001
137+
ARG USER_GID=1001
46138
RUN groupadd --gid $USER_GID $USERNAME
47139
RUN 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
51143
USER $USERNAME
52144

53145
# install Rust environment
146+
ARG RUSTC_VERSION=1.90.0
54147
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
148+
55149
ENV 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
58159
ARG PGRX_VERSION=0.16.1
59160
RUN 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
64187
ENV USER=$USERNAME

.devcontainer/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Devcontainer
2+
If you install devcontainer extension at vscode, you can spin up your development environment via pg_parquet devcontainer. All necessary components and dependencies would be installed in your environment after the spin-up. You can work in the container as if it is your development environment. (git, make, aws cli and postgres commands should work seamlessly) The container offers reproducible environment as we use the same dockerfile for CI and devcontainer.
3+
4+
## Prerequisites
5+
1. Make sure to allocate >= ~10GB memory resource to docker.
6+
2. Your `~/.aws` folder is mounted as a read only volume to pg_parquet container so that it can read/write buckets with your aws credentials. You are expected to set up your aws credentials before. (possible to read/write from/to **production** s3 buckets)
7+
8+
After opening the project inside the devcontainer, you can do the following steps:
9+
10+
1. Connect to the postgres server (build takes place at the first run)
11+
```bash
12+
cargo pgrx run
13+
```
14+
2. Create pg_parquet extension
15+
```sql
16+
pg_parquet=# create extension pg_parquet;
17+
CREATE EXTENSION
18+
```
19+
3. Copy test data to parquet file
20+
```sql
21+
pg_parquet=# copy (select i from generate_series(1, 10) i) to '/tmp/test.parquet';
22+
COPY 10
23+
```

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "pg_parquet Dev Environment",
33
"dockerComposeFile": "docker-compose.yml",
4-
"service": "app",
4+
"service": "pg_parquet",
55
"workspaceFolder": "/workspace",
6-
"postAttachCommand": "sudo chown -R rust /workspace",
6+
"remoteUser": "rust",
7+
"containerUser": "rust",
78
"customizations": {
89
"vscode": {
910
"extensions": [

0 commit comments

Comments
 (0)