|
| 1 | + |
| 2 | +FROM ubuntu:jammy |
| 3 | +LABEL maintainer="team@postgresml.com" |
| 4 | + |
| 5 | +ARG PG_MAJOR_VER |
| 6 | +ENV PG_MAJOR_VER=${PG_MAJOR_VER} |
| 7 | + |
| 8 | +RUN apt-get update |
| 9 | +ARG DEBIAN_FRONTEND=noninteractive |
| 10 | +ENV TZ=Etc/UTC |
| 11 | +RUN apt-get install -y software-properties-common |
| 12 | +RUN add-apt-repository ppa:apt-fast/stable --yes |
| 13 | +RUN apt update && apt-get install -y apt-fast |
| 14 | +RUN apt-get update && apt-fast install -y \ |
| 15 | + libopenblas-dev \ |
| 16 | + libssl-dev \ |
| 17 | + bison \ |
| 18 | + flex \ |
| 19 | + pkg-config \ |
| 20 | + cmake \ |
| 21 | + libreadline-dev \ |
| 22 | + libz-dev \ |
| 23 | + curl \ |
| 24 | + lsb-release \ |
| 25 | + tzdata \ |
| 26 | + sudo \ |
| 27 | + cmake \ |
| 28 | + libpq-dev \ |
| 29 | + libclang-dev \ |
| 30 | + wget \ |
| 31 | + postgresql-plpython3-$PG_MAJOR_VER \ |
| 32 | + postgresql-$PG_MAJOR_VER \ |
| 33 | + postgresql-server-dev-$PG_MAJOR_VER \ |
| 34 | + git |
| 35 | + |
| 36 | +RUN add-apt-repository ppa:deadsnakes/ppa --yes |
| 37 | +RUN apt update && apt-fast install -y \ |
| 38 | + python3.10 \ |
| 39 | + python3-pip \ |
| 40 | + libpython3.10-dev \ |
| 41 | + python3.10-dev |
| 42 | + |
| 43 | + |
| 44 | +RUN echo 'postgres ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers |
| 45 | + |
| 46 | + |
| 47 | +COPY ./pgml-extension/requirements.txt /app/requirements.txt |
| 48 | + |
| 49 | + |
| 50 | +RUN pip3 install -r /app/requirements.txt |
| 51 | + |
| 52 | + |
| 53 | +# Running pgrx and tests require a non-root user |
| 54 | +WORKDIR /app |
| 55 | + |
| 56 | +RUN chmod a+rwx `$(which pg_config) --pkglibdir` \ |
| 57 | + `$(which pg_config) --sharedir`/extension \ |
| 58 | + /var/run/postgresql/ |
| 59 | + |
| 60 | +RUN useradd postgresml -m -s /bin/bash -G sudo |
| 61 | +RUN echo 'postgresml ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers |
| 62 | + |
| 63 | +USER postgresml |
| 64 | + |
| 65 | + |
| 66 | +# Install cargo and Rust |
| 67 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 68 | +ENV PATH="/home/postgresml/.cargo/bin:${PATH}" |
| 69 | + |
| 70 | + |
| 71 | +# Install pgrx |
| 72 | +RUN cargo install cargo-pgrx --version "0.8.2" --locked |
| 73 | + |
| 74 | + |
| 75 | +COPY --chown=postgresml:postgresml ./ /app |
| 76 | +RUN sudo chown -R postgresml:postgresml /app |
| 77 | +RUN git submodule update --init --recursive |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +RUN sudo cp /app/pgml-extension/docker/postgresql.conf /etc/postgresql/$PG_MAJOR_VER/main/postgresql.conf |
| 83 | +RUN sudo cp /app/pgml-extension/docker/pg_hba.conf /etc/postgresql/$PG_MAJOR_VER/main/pg_hba.conf |
| 84 | + |
| 85 | + |
| 86 | +# RUN sudo chown -R rust:rust /usr/share/postgresql/$PG_MAJOR_VER/extension |
| 87 | +RUN sudo chown -R postgresml:postgresml /usr/share/postgresql/$PG_MAJOR_VER/ |
| 88 | +RUN sudo chown -R postgresml:postgresml /usr/share/postgresql/$PG_MAJOR_VER/extension |
| 89 | + |
| 90 | +# commenting this three make things work |
| 91 | +# USER rust |
| 92 | + |
| 93 | +RUN cd /app/pgml-extension && cargo pgrx init --pg$PG_MAJOR_VER=$(which pg_config) |
| 94 | +RUN cd /app/pgml-extension && cargo pgrx install --pg-config $(which pg_config) |
| 95 | + |
| 96 | +EXPOSE 5432 |
| 97 | + |
| 98 | +USER postgres |
| 99 | + |
| 100 | +CMD ["/usr/lib/postgresql/14/bin/postgres", "-c", "config_file=/etc/postgresql/14/main/postgresql.conf"] |
| 101 | + |
0 commit comments