Skip to content

Commit ac1c646

Browse files
authored
Docker local dev (#536)
1 parent b14128b commit ac1c646

File tree

3 files changed

+86
-75
lines changed

3 files changed

+86
-75
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build PostgresML Rust package
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest]
11+
runs-on: ${{ matrix.os }}
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Install dependencies
15+
run:
16+
sudo apt update
17+
sudo apt install -y ruby curl
18+
curl -sLO https://github.com/deb-s3/deb-s3/releases/download/0.11.4/deb-s3-0.11.4.gem
19+
sudo gem install deb-s3-0.11.4.gem
20+
- name: Build package
21+
run:
22+
docker run -v $(pwd):/app levkk/postgresml:build cargo pgx package --pg-control /usr/lib/postgresql/11/bin/pg_config
23+
docker run -v $(pwd):/app levkk/postgresml:build cargo pgx package --pg-control /usr/lib/postgresql/12/bin/pg_config
24+
docker run -v $(pwd):/app levkk/postgresml:build cargo pgx package --pg-control /usr/lib/postgresql/13/bin/pg_config
25+
docker run -v $(pwd):/app levkk/postgresml:build cargo pgx package --pg-control /usr/lib/postgresql/14/bin/pg_config
26+
docker run -v $(pwd):/app levkk/postgresml:build cargo pgx package --pg-control /usr/lib/postgresql/15/bin/pg_config
27+
# - name: Publish package
28+
# env:
29+
# AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
30+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31+
# AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
32+
# working-directory: postgresml/pgml-extension
33+
# run: |
34+
# if [[ $(uname -a) == *"aarch64"* ]]; then
35+
# ARCH="arm64"
36+
# else
37+
# ARCH="amd64"
38+
# fi
39+
40+
# deb-s3 upload \
41+
# --bucket apt.postgresml.org \
42+
# postgresql-pgml-${{ inputs.postgresVersion }}_${{ inputs.packageVersion }}-ubuntu${{ inputs.ubuntuVersion }}-${ARCH}.deb \
43+
# --codename ${{ inputs.ubuntuName }}

pgml-extension/Dockerfile

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,47 @@
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
84
ARG DEBIAN_FRONTEND=noninteractive
9-
ARG PACKAGE_VERSION=2.0.0
10-
ARG PACKAGE_PYTHON=true
11-
ARG PACKAGE_CUDA=false
125
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
177
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
4039
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
4947
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"]

pgml-extension/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
# PostgresML Extension
2-
3-
PostgresML is a PostgreSQL extension providing end-to-end machine learning inside your database. The extension is primarily written in Rust using [pgx](https://github.com/tcdi/pgx) and provides a SQL interface to various machine learning algorithm implementations such as [XGBoost](https://github.com/dmlc/xgboost), [LightGBM](https://github.com/microsoft/LightGBM), and [other classical methods](https://github.com/rust-ml/linfa).
4-
5-
See [our blog](https://postgresml.org/blog/postgresml-is-moving-to-rust-for-our-2.0-release/) for a performance comparison and further motivations.
6-
7-
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.
1+
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy