From fd4f68e859855ab1782d32fb4dbadc0e09e423cc Mon Sep 17 00:00:00 2001 From: stijndcl Date: Mon, 6 May 2024 16:46:11 +0200 Subject: [PATCH 1/3] Migrate image to psql --- unipept-database/Dockerfile | 14 ++++---------- unipept-database/db_entrypoint.sh | 11 +++++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/unipept-database/Dockerfile b/unipept-database/Dockerfile index 564bda6..97abe35 100755 --- a/unipept-database/Dockerfile +++ b/unipept-database/Dockerfile @@ -1,4 +1,4 @@ -FROM mariadb:jammy +FROM postgres:16.2-bullseye ### # Name: unipept-database @@ -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/) @@ -92,4 +86,4 @@ ENV VERBOSE false ENV SORT_MEMORY 2G -EXPOSE 3306 +EXPOSE 5432 diff --git a/unipept-database/db_entrypoint.sh b/unipept-database/db_entrypoint.sh index dd6e48b..b467e68 100755 --- a/unipept-database/db_entrypoint.sh +++ b/unipept-database/db_entrypoint.sh @@ -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 From eca5fe66d0dbecd3a1878f6ba0b15dba03be2e82 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Mon, 6 May 2024 19:05:48 +0200 Subject: [PATCH 2/3] Remove mariadb config file --- unipept-database/config/custom_mysql_config.cnf | 7 ------- 1 file changed, 7 deletions(-) delete mode 100755 unipept-database/config/custom_mysql_config.cnf diff --git a/unipept-database/config/custom_mysql_config.cnf b/unipept-database/config/custom_mysql_config.cnf deleted file mode 100755 index 0c4ddbc..0000000 --- a/unipept-database/config/custom_mysql_config.cnf +++ /dev/null @@ -1,7 +0,0 @@ -[mysqld] -secure-file-priv = "" -local-infile=1 -default-authentication-plugin=mysql_native_password -innodb_buffer_pool_size=2048M -innodb_flush_log_at_trx_commit = 0 -innodb_file_per_table From a645b3cbe6e77ab3806e7a0926ca9394e98a8b36 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Mon, 6 May 2024 19:13:51 +0200 Subject: [PATCH 3/3] Change web db ports --- unipept-web/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unipept-web/Dockerfile b/unipept-web/Dockerfile index 79e2200..a16f043 100755 --- a/unipept-web/Dockerfile +++ b/unipept-web/Dockerfile @@ -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