|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +FROM golang:1.26.2-alpine AS golang_cgo |
| 3 | +ENV CGO_ENABLED=1 |
| 4 | +ENV GO_LDFLAGS="-linkmode external -extldflags '-static'" |
| 5 | +RUN apk add --no-cache build-base |
| 6 | + |
| 7 | +# --- Build doltgres binary --- |
| 8 | +FROM golang_cgo AS doltgres_build |
| 9 | +RUN apk add --no-cache icu-dev icu-static |
| 10 | +RUN apk update && apk add --no-cache bash |
| 11 | +WORKDIR /root/building |
| 12 | +COPY go.mod doltgresql/ |
| 13 | +WORKDIR doltgresql |
| 14 | +RUN go mod download |
| 15 | +COPY --exclude=testing/postgres-client-tests/ . . |
| 16 | +WORKDIR /root/building/doltgresql/postgres/parser |
| 17 | +RUN sh ./build.sh |
| 18 | +WORKDIR /root/building/doltgresql/cmd/doltgres |
| 19 | +RUN go build -ldflags "-linkmode external -extldflags '-static'" -o /build/bin/doltgres . |
| 20 | + |
| 21 | +# --- Build Go postgres clients (pgx, lib/pq) --- |
| 22 | +FROM golang:1.26.4 AS go_clients_build |
| 23 | +COPY testing/postgres-client-tests/go/pgx/ /build/go/pgx/ |
| 24 | +WORKDIR /build/go/pgx |
| 25 | +RUN go build -o /build/bin/pgx-test . |
| 26 | +COPY testing/postgres-client-tests/go/libpq/ /build/go/libpq/ |
| 27 | +WORKDIR /build/go/libpq |
| 28 | +RUN go build -o /build/bin/libpq-test . |
| 29 | + |
| 30 | +# --- Build Rust sqlx client --- |
| 31 | +FROM rust:1.96-slim-bookworm AS rust_clients_build |
| 32 | +RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/* |
| 33 | +COPY testing/postgres-client-tests/rust/ /build/rust/ |
| 34 | +WORKDIR /build/rust |
| 35 | +RUN cargo build --release |
| 36 | + |
| 37 | +# --- Build C libpq client --- |
| 38 | +FROM debian:bookworm-slim AS c_clients_build |
| 39 | +RUN apt-get update && apt-get install -y gcc make libpq-dev pkg-config && rm -rf /var/lib/apt/lists/* |
| 40 | +COPY testing/postgres-client-tests/c/ /build/c/ |
| 41 | +WORKDIR /build/c |
| 42 | +RUN make |
| 43 | + |
| 44 | +# --- Install Node postgres client deps --- |
| 45 | +FROM node:22-bookworm-slim AS node_clients_build |
| 46 | +COPY testing/postgres-client-tests/node/package.json /build/node/ |
| 47 | +COPY testing/postgres-client-tests/node/package-lock.json /build/node/ |
| 48 | +WORKDIR /build/node |
| 49 | +RUN npm install |
| 50 | +COPY testing/postgres-client-tests/node/ /build/node/ |
| 51 | + |
| 52 | +# --- Install Ruby pg gem --- |
| 53 | +FROM ruby:3.4-bookworm AS ruby_clients_build |
| 54 | +RUN apt-get update && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* |
| 55 | +COPY testing/postgres-client-tests/ruby/Gemfile /build/ruby/ |
| 56 | +COPY testing/postgres-client-tests/ruby/Gemfile.lock /build/ruby/ |
| 57 | +WORKDIR /build/ruby |
| 58 | +RUN bundle install |
| 59 | +COPY testing/postgres-client-tests/ruby/ /build/ruby/ |
| 60 | + |
| 61 | +# --- Install Python deps --- |
| 62 | +FROM python:3.14-slim-bookworm AS python_clients_build |
| 63 | +RUN pip3 install --no-cache-dir --target /build/python-deps sqlalchemy==2.0.46 |
| 64 | +COPY testing/postgres-client-tests/python/ /build/python/ |
| 65 | +WORKDIR /build/python/ |
| 66 | + |
| 67 | +# --- Build .NET Npgsql client --- |
| 68 | +FROM mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS dotnet_clients_build |
| 69 | +COPY testing/postgres-client-tests/dotnet/ /build/dotnet/ |
| 70 | +WORKDIR /build/dotnet |
| 71 | +RUN dotnet publish -c Release -o /build/output/ |
| 72 | + |
| 73 | +# --- Runtime --- |
| 74 | +FROM debian:bookworm-slim |
| 75 | + |
| 76 | +ENV DEBIAN_FRONTEND=noninteractive |
| 77 | + |
| 78 | +RUN apt-get update && apt-get install -y \ |
| 79 | + curl \ |
| 80 | + gnupg \ |
| 81 | + lsb-release && \ |
| 82 | + sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \ |
| 83 | + curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \ |
| 84 | + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - |
| 85 | + |
| 86 | +# java JDBC dependencies |
| 87 | +COPY testing/postgres-client-tests/java/ /postgres-client-tests/java/ |
| 88 | +RUN apt-get install -y \ |
| 89 | + openjdk-17-jdk && \ |
| 90 | + curl -L -o /postgres-client-tests/java/postgresql-42.7.3.jar https://jdbc.postgresql.org/download/postgresql-42.7.3.jar |
| 91 | + |
| 92 | +# perl dependencies |
| 93 | +RUN apt-get install -y \ |
| 94 | + python3 \ |
| 95 | + python3-pip \ |
| 96 | + python3-psycopg2 \ |
| 97 | + perl \ |
| 98 | + cpanminus \ |
| 99 | + php \ |
| 100 | + php-pgsql \ |
| 101 | + r-base \ |
| 102 | + libpq-dev \ |
| 103 | + ca-certificates-java \ |
| 104 | + bats \ |
| 105 | + lsof \ |
| 106 | + postgresql-client-15 \ |
| 107 | + nodejs \ |
| 108 | + elixir \ |
| 109 | + libicu-dev \ |
| 110 | + git && \ |
| 111 | + update-ca-certificates -f && \ |
| 112 | + rm -rf /var/lib/apt/lists/* |
| 113 | + |
| 114 | +# install .NET |
| 115 | +RUN curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh \ |
| 116 | + && chmod +x dotnet-install.sh \ |
| 117 | + && ./dotnet-install.sh --channel 9.0 --runtime aspnetcore --install-dir /usr/share/dotnet \ |
| 118 | + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \ |
| 119 | + && rm dotnet-install.sh |
| 120 | + |
| 121 | +# cpan dependencies |
| 122 | +RUN cpanm --force DBD::Pg |
| 123 | + |
| 124 | +# r dependencies |
| 125 | +COPY testing/postgres-client-tests/r/ /postgres-client-tests/r/ |
| 126 | +RUN Rscript -e 'install.packages("RPostgres", repos="https://cloud.r-project.org")' |
| 127 | + |
| 128 | +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ |
| 129 | +ENV GEM_HOME="/usr/local/bundle" |
| 130 | +ENV PYTHONPATH=/usr/local/lib/python-deps |
| 131 | + |
| 132 | +COPY --from=ruby_clients_build /usr/local/bin/ruby /usr/local/bin/ |
| 133 | +COPY --from=ruby_clients_build /usr/local/lib/ /usr/local/lib/ |
| 134 | +COPY --from=ruby_clients_build /usr/local/bundle/ /usr/local/bundle/ |
| 135 | +RUN ldconfig |
| 136 | + |
| 137 | +COPY --from=doltgres_build /build/bin/doltgres /usr/local/bin/doltgres |
| 138 | +COPY --from=go_clients_build /build/bin/pgx-test /build/bin/go/pgx-test |
| 139 | +COPY --from=go_clients_build /build/bin/libpq-test /build/bin/go/libpq-test |
| 140 | +COPY --from=rust_clients_build /build/rust/target/release/sqlx_exists_demo /build/bin/rust/sqlx_exists_demo |
| 141 | +COPY --from=c_clients_build /build/c/postgres-c-connector-test /build/bin/c/postgres-c-connector-test |
| 142 | +COPY --from=dotnet_clients_build /build/output /build/bin/dotnet |
| 143 | +COPY --from=node_clients_build /build/node/ /postgres-client-tests/node/ |
| 144 | +COPY --from=python_clients_build /build/python/ /postgres-client-tests/python/ |
| 145 | +COPY --from=python_clients_build /build/python-deps/ /usr/local/lib/python-deps/ |
| 146 | +COPY --from=ruby_clients_build /build/ruby/ /postgres-client-tests/ruby/ |
| 147 | + |
| 148 | +COPY testing/postgres-client-tests/c/ /postgres-client-tests/c/ |
| 149 | +COPY testing/postgres-client-tests/drizzle/ /postgres-client-tests/drizzle/ |
| 150 | +COPY testing/postgres-client-tests/helpers.bash /postgres-client-tests/ |
| 151 | +COPY testing/postgres-client-tests/php/ /postgres-client-tests/php/ |
| 152 | +COPY testing/postgres-client-tests/perl/ /postgres-client-tests/perl/ |
| 153 | +COPY testing/postgres-client-tests/postgres-client-tests.bats /postgres-client-tests/ |
| 154 | +COPY testing/postgres-client-tests/postgres-client-tests-entrypoint.sh /postgres-client-tests/entrypoint.sh |
| 155 | + |
| 156 | +WORKDIR /postgres-client-tests |
| 157 | +ENTRYPOINT ["/postgres-client-tests/entrypoint.sh"] |
0 commit comments