Last active
November 28, 2021 15:00
-
-
Save tae898/1158659c657daca167c57f00b5d0c4bc to your computer and use it in GitHub Desktop.
Dockerfile for running postgres and conceptnet5 locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start from the official postgres image | |
FROM postgres | |
# Adding the below environment variables allow you to create a database easily within | |
# the docker contianer | |
ENV POSTGRES_USER root | |
ENV POSTGRES_PASSWORD root | |
ENV POSTGRES_DB root | |
# Install the necessary libraries for both postgres and conceptnet | |
RUN apt update | |
RUN apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev -y | |
RUN apt install libreadline-dev libffi-dev curl libbz2-dev libsqlite3-dev git unzip -y | |
RUN apt install wget libhdf5-dev libmecab-dev mecab-ipadic-utf8 liblzma-dev lzma -y | |
# Change the default shell to `zsh` since I like it. | |
RUN apt install watch htop zsh -y | |
RUN chsh -s $(which zsh) | |
RUN sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# Install python 3.7.12 | |
# Somehow I couldn't just `apt install python3.7`. Here I manually download and compile it. | |
RUN wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz | |
RUN tar -xf Python-3.7.12.tgz | |
WORKDIR "/Python-3.7.12" | |
RUN ./configure --enable-optimizations --enable-loadable-sqlite-extensions | |
RUN make -j$(nproc) | |
RUN make install | |
RUN apt install python3-pip python3-dev -y | |
# Install conceptnet | |
WORKDIR "/" | |
RUN git clone https://github.com/commonsense/conceptnet5.git | |
WORKDIR "/conceptnet5" | |
# modify `build.sh` in place to speed up processing | |
RUN sed -i -e 's/-j 2/-j$(nproc) /g' build.sh | |
RUN pip3 install --upgrade pip | |
RUN pip3 install wheel | |
RUN pip3 install -e '.[vectors]' | |
CMD [ "postgres" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A big part of the instruction below is copied from here.
You don't have to build the docker image again, since I've already pushed to docker hub.
Here is how to get things done:
Pull the image and run it in detached mode by running
The docker container with the name
conceptnet5
container will be running now.Open up zsh (or bash, whatever you prefer) in the container by running
docker exec -it conceptnet5 zsh
Create a PostgreSQL database named
conceptnet5
by runningStart the build by running
This will take a long time since it has to download all the data.