Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Postgres, use parallel db scripts #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions unipept-database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mariadb:jammy
FROM postgres:16.2-bullseye

###
# Name: unipept-database
Expand Down Expand Up @@ -49,20 +49,14 @@ RUN apt update && \
sudo \
lz4


# Configure curl to use the newly builded libcurl
#RUN ldconfig

RUN git clone --depth 1 https://github.com/unipept/unipept-database
# TODO change to unipept repo once changes are merged to master!
RUN git clone --depth 1 -b feature/postgres https://github.com/stijndcl/unipept-database
COPY "db_entrypoint.sh" "/docker-entrypoint-initdb.d/db_entrypoint.sh"

# Sometimes, these files are copied over from Windows systems and need to be converted into Unix line endings to make
# sure that these can be properly executed by the container.
RUN dos2unix /unipept-database/scripts/**/*.sh && chmod u+x /unipept-database/scripts/*.sh

COPY "config/custom_mysql_config.cnf" "/etc/mysql/conf.d/custom_mysql_config.cnf"
RUN chmod a-w "/etc/mysql/conf.d/custom_mysql_config.cnf"

RUN echo 'root:unipept' | chpasswd

# Install Rust toolchain (https://rustup.rs/)
Expand Down Expand Up @@ -92,4 +86,4 @@ ENV VERBOSE false

ENV SORT_MEMORY 2G

EXPOSE 3306
EXPOSE 5432
7 changes: 0 additions & 7 deletions unipept-database/config/custom_mysql_config.cnf

This file was deleted.

11 changes: 7 additions & 4 deletions unipept-database/db_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ echo "unipept" | su -c "./scripts/build_database.sh $VERBOSE-f $FILTER_TAXA -i '

echo "***** START LOADING TABLES *****"

# Data has been generated by this point. Now, we can load it into the MySQL-database for use later on.
mariadb -uunipept -punipept < schemas/structure_no_index.sql
echo "unipept" | su -c "./scripts/load.sh '/tmp/tables'" root
# Data has been generated by this point. Now, we can load it into the PSQL-database for use later on.
PGPASSWORD=unipept psql -U unipept < schemas/structure_no_index_no_constraints.sql
echo "unipept" | su -c "./scripts/parallel_load.sh '/tmp/tables'" root
rm -f '/tables/**/*.tsv.lz4'

echo "***** START APPLYING CONSTRAINTS *****"
PGPASSWORD=unipept psql -U unipept < schemas/structure_constraints_only.sql

echo "***** START INDEXING TABLES *****"

echo "unipept" | su -c "./scripts/index.sh" root
echo "unipept" | su -c "./scripts/parallel_index.sh" root
4 changes: 2 additions & 2 deletions unipept-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ RUN apt-get autoremove -y \

RUN git clone https://github.com/unipept/unipept-api.git
RUN cd unipept-api && git checkout main && gem install bundler
RUN cd unipept-api/config && printf " host: host.docker.internal\n port: 3306\n" >> database.yml
RUN cd unipept-api/config && printf " host: host.docker.internal\n port: 5432\n" >> database.yml
RUN cd unipept-api && bundle install

ENV RAILS_ENV=production
ENV DB_PORT=3300

CMD cd unipept-api && sed -i "s/port: 3306/port: $DB_PORT/g" config/database.yml && bundle exec rails server -b 0.0.0.0 -e production
CMD cd unipept-api && sed -i "s/port: 5432/port: $DB_PORT/g" config/database.yml && bundle exec rails server -b 0.0.0.0 -e production