|
1 |
| -# |
2 |
| -# Extension builder. |
3 |
| -# |
4 |
| -ARG UBUNTU_VERSION=22.04 |
5 |
| -FROM ubuntu:${UBUNTU_VERSION} |
6 |
| - |
7 |
| -ARG PGVERSION=14 |
| 1 | +FROM ubuntu:jammy |
| 2 | +MAINTAINER team@postgresml.com |
| 3 | +RUN apt-get update |
8 | 4 | ARG DEBIAN_FRONTEND=noninteractive
|
9 |
| -ARG PACKAGE_VERSION=2.0.0 |
10 |
| -ARG PACKAGE_PYTHON=true |
11 |
| -ARG PACKAGE_CUDA=false |
12 | 5 | ENV TZ=Etc/UTC
|
13 |
| - |
14 |
| -# Apt-fast |
15 |
| -RUN apt-get update && apt-get install software-properties-common -y |
16 |
| - |
| 6 | +RUN apt-get install -y software-properties-common |
17 | 7 | RUN add-apt-repository ppa:apt-fast/stable --yes
|
18 |
| -RUN apt-get update && apt-get -y install apt-fast |
19 |
| - |
20 |
| -RUN apt-fast install apt-fast curl unzip gpg wget -y |
21 |
| - |
22 |
| -# PostgreSQL |
23 |
| -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null |
24 |
| -RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list |
25 |
| - |
26 |
| -# CMake |
27 |
| -RUN curl -L https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null |
28 |
| -RUN echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null |
29 |
| - |
30 |
| -RUN apt-get update && apt-fast install postgresql-${PGVERSION} libopenblas-dev cmake postgresql-server-dev-${PGVERSION} pkg-config libssl-dev build-essential libclang-dev clang libpython3-dev python3-dev -y |
31 |
| - |
32 |
| -# CUDA |
33 |
| -COPY docker/install_cuda.sh install_cuda.sh |
34 |
| -RUN bash install_cuda.sh |
35 |
| - |
36 |
| -USER postgres |
37 |
| - |
38 |
| - |
39 |
| -# Install Rust |
| 8 | +RUN apt update && apt-get install -y apt-fast |
| 9 | +RUN apt-get update && apt-fast install -y \ |
| 10 | + libopenblas-dev \ |
| 11 | + libssl-dev \ |
| 12 | + bison \ |
| 13 | + flex \ |
| 14 | + pkg-config \ |
| 15 | + cmake \ |
| 16 | + libreadline-dev \ |
| 17 | + libz-dev \ |
| 18 | + curl \ |
| 19 | + lsb-release \ |
| 20 | + tzdata \ |
| 21 | + sudo \ |
| 22 | + cmake \ |
| 23 | + libpq-dev \ |
| 24 | + libclang-dev \ |
| 25 | + wget \ |
| 26 | + postgresql-plpython3-14 \ |
| 27 | + postgresql-14 \ |
| 28 | + postgresql-server-dev-14 |
| 29 | +RUN add-apt-repository ppa:deadsnakes/ppa --yes |
| 30 | +RUN apt update && apt-fast install -y \ |
| 31 | + python3.10 \ |
| 32 | + python3-pip \ |
| 33 | + libpython3.10-dev \ |
| 34 | + python3.10-dev |
| 35 | +RUN pip3 install xgboost scikit-learn torch lightgbm transformers datasets |
| 36 | +RUN useradd postgresml -m -s /bin/bash -G sudo |
| 37 | +RUN echo 'postgresml ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers |
| 38 | +USER postgresml |
40 | 39 | RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
|
41 |
| -ENV PATH="/var/lib/postgresql/.cargo/bin:${PATH}" |
42 |
| - |
43 |
| -# Install tcdi/pgx |
44 |
| -RUN cargo install cargo-pgx --version 0.7.1 |
45 |
| -RUN cargo pgx init --pg${PGVERSION} /usr/bin/pg_config |
46 |
| - |
47 |
| - |
48 |
| -COPY --chown=postgres:postgres . /app |
| 40 | +RUN $HOME/.cargo/bin/cargo install cargo-pgx --version "0.7.1" |
| 41 | +RUN $HOME/.cargo/bin/cargo pgx init |
| 42 | +RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null |
| 43 | +RUN sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
| 44 | +RUN sudo apt update |
| 45 | +RUN sudo apt-get install -y postgresql-15 postgresql-13 postgresql-12 postgresql-11 |
| 46 | +RUN sudo apt install -y postgresql-server-dev-15 postgresql-server-dev-15 postgresql-server-dev-12 postgresql-server-dev-11 |
49 | 47 | WORKDIR /app
|
50 |
| - |
51 |
| - |
52 |
| -# cargo pgx package command ignores --no-default-features sadly, so we |
53 |
| -# have to have a separate Cargo.toml without Python. No big deal. |
54 |
| -# Make sure to diff it and update it if you change the main Cargo.toml. |
55 |
| -ENV PACKAGE_PYTHON=${PACKAGE_PYTHON} |
56 |
| -RUN bash -c 'if [[ "${PACKAGE_PYTHON}" == "false" ]]; then cp docker/Cargo.toml.no-python Cargo.toml; fi' |
57 |
| - |
58 |
| -ENV PACKAGE_CUDA=${PACKAGE_CUDA} |
59 |
| -RUN bash -c 'if [[ "${PACKAGE_CUDA}" == "true" ]]; then cp docker/Cargo.toml.cuda Cargo.toml; fi' |
60 |
| - |
61 |
| -# Build and upload package to S3 |
62 |
| -ENV CUDACXX=/usr/local/cuda/bin/nvcc |
63 |
| -RUN cargo pgx package |
64 |
| - |
65 |
| -# Deb file goes here, mount it on your local system |
66 |
| -VOLUME /output |
67 |
| -USER root |
68 |
| - |
69 |
| -ENV PACKAGE_VERSION=$PACKAGE_VERSION |
70 |
| -ENV OUTPUT_DIR=/output |
71 |
| - |
72 |
| -# Run |
73 |
| -ENTRYPOINT ["bash", "docker/build_ubuntu_deb.sh", "/output"] |
0 commit comments