forked from neurdb/neurdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.cpu
More file actions
130 lines (108 loc) · 4.19 KB
/
Dockerfile.cpu
File metadata and controls
130 lines (108 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Use the ci-ready Ubuntu 22.04 as the base image
FROM ciready/ubuntu:22.04-ci-c
# Expose port
EXPOSE 5432
# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Upgrade pip
RUN apt-get update
RUN apt-get install -y \
python3-dev \
python3-pip
# Install locale support and generate en_US.UTF-8
RUN apt-get install -y locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
# Set locale environment variables
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8
# Update package list and install necessary packages including Python 3.8, psycopg2, and LLVM distutils
RUN apt-get install -y \
python-is-python3 \
sudo \
curl \
git \
vim \
wget \
unzip \
pkg-config \
build-essential \
libssl-dev \
make \
cmake \
gcc \
gdb \
gdbserver \
net-tools \
lsof \
clang \
flex \
bison \
libreadline-dev \
zlib1g-dev \
libicu-dev \
libclang-dev \
llvm-dev \
libcurl4-openssl-dev \
libwebsockets-dev \
libcjson-dev \
librocksdb-dev \
libpqxx-dev \
libopencv-dev \
&& apt-get clean
# Download libtorch CPU version and extract it to /home
# RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.1%2Bcpu.zip
# RUN unzip libtorch-cxx11-abi-shared-with-deps-2.3.1+cpu.zip -d /home
# Set root password
RUN echo "root:rootpassword" | chpasswd
# Create a non-root user 'neurdb' with an empty password and add to sudoers
RUN useradd -m -s /bin/bash neurdb && \
passwd -d neurdb && \
echo "neurdb ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Install Rust using rustup and cargo-pgrx as the neurdb user
# Ensure rustc 1.78.0 rustc --version
# Ensure cargo-pgrx v0.11.4 cargo-pgrx --version
# USER neurdb
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
# echo 'source $HOME/.cargo/env' >> $HOME/.bashrc && \
# /bin/bash -c "source $HOME/.cargo/env && rustup install 1.78.0" && \
# /bin/bash -c "source $HOME/.cargo/env && cargo install cargo-pgrx --version '0.11.4' --locked"
# Switch back to root to set system-wide environment variables
USER root
# Set the path for Rust and Cargo for both root and neurdb users
# ENV PATH="/home/neurdb/.cargo/bin:${PATH}"
# RUN echo 'export PATH="$PATH:/home/neurdb/.cargo/bin"' >> /etc/profile
# RUN echo 'export PATH="$PATH:/home/neurdb/.cargo/bin"' >> /home/neurdb/.bashrc
# Set environment variables for both root and other users
ENV PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig"
ENV LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
ENV NEURDBPATH="/code/neurdb-dev"
# Set the working directory
WORKDIR $NEURDBPATH
# Add environmental variables
RUN echo "export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> /etc/profile && \
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> /etc/profile && \
echo 'export LIBCLANG_PATH=$(llvm-config --libdir)' >> /etc/profile && \
echo "export NEURDBPATH=${NEURDBPATH}" >> /etc/profile && \
echo "export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> /home/neurdb/.bashrc && \
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> /home/neurdb/.bashrc && \
echo 'export LIBCLANG_PATH=$(llvm-config --libdir)' >> /home/neurdb/.bashrc && \
echo "export NEURDBPATH=${NEURDBPATH}" >> /home/neurdb/.bashrc && \
echo "export PATH=${PATH}:/home/neurdb/.local/bin:${NEURDBPATH}/psql/bin" >> /home/neurdb/.bashrc
# Install Python packages
USER neurdb
COPY aiengine/runtime/requirements.cpu.txt /usr/local/bin/requirements.txt
RUN pip install -r /usr/local/bin/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
# Copy the build script into the container
USER root
COPY docker-init.sh /usr/local/bin/docker-init.sh
# Ensure the build script is executable
RUN chmod +x /usr/local/bin/docker-init.sh
# Change to non-root user 'neurdb' for database compilation and running the init script
USER neurdb
# Add env path and fix git ownership.
ENV PATH="/home/neurdb/.local/bin:${PATH}"
RUN git config --global --add safe.directory /code/neurdb-dev
# Command to run the init.sh script
CMD ["bash", "/usr/local/bin/docker-init.sh"]