Skip to content

Commit 448b10b

Browse files
authored
Development dockerfile (#685)
1 parent cbbf028 commit 448b10b

File tree

3 files changed

+116
-49
lines changed

3 files changed

+116
-49
lines changed

Dockerfile.local

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+

docker-compose.local.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "3"
2+
# Run by doing docker compose -f docker-compose.local.yml build --build-arg PG_MAJOR_VER=14
3+
# docker compose -f docker-compose.local.yml up
4+
services:
5+
postgres:
6+
healthcheck:
7+
test: [ "CMD-SHELL", "pg_isready" ]
8+
interval: 1s
9+
timeout: 5s
10+
retries: 100
11+
build:
12+
context: .
13+
dockerfile: Dockerfile.local
14+
ports:
15+
- "5433:5432"

pgml-extension/Dockerfile.local

Lines changed: 0 additions & 49 deletions
This file was deleted.

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