diff --git a/Dockerfile b/Dockerfile index 959b432..c759fc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM node:18-bullseye LABEL maintainer="Emerson Rocha <rocha@ieee.org>" +ARG UWAZI_GIT_RELEASE_REF=production + # see https://github.com/nodejs/docker-node#how-to-use-this-image ## Install common software @@ -26,7 +28,7 @@ RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] http://rep && apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN git clone -b production --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ +RUN git clone -b "$UWAZI_GIT_RELEASE_REF" --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ && chown node:node -R /home/node/uwazi/ \ && cd /home/node/uwazi/ \ && yarn install \ diff --git a/README.md b/README.md index 26fdf26..d0d083b 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,32 @@ cd uwazi-docker docker compose run -e IS_FIRST_RUN=true --rm uwazi # Install/Re-install from empty data ``` -<!-- docker compose run --rm uwazi-installer --> + +With very fast internet and disks, this step will take between 8 to 15 minutes. ### Run ```bash -docker compose up -d uwazi # Run uwazi on background (automatic restart on reboot unless stopped) +# Run uwazi on background (automatic restart on reboot unless stopped) +docker compose up -d uwazi ``` Open your browser at <http://localhost:3000/>. Initial user: `admin`, password: `change this password now`. +#### `yarn migrate` and `yarn reindex` + +At installation step the `yarn migrate` and `yarn reindex` are always executed, +however the database will be erased to a blank state. +However, if for some you already have real data and not major database upgrade, +in which MongoDB and ElasticSearch might need some minor custom steps outside of Uwazi control, +this command will run once only the `yarn migrate` and `yarn reindex`. + +```bash +docker compose run -e RUN_YARN_MIGRATE_REINDEX=true --rm uwazi +``` + +Just to be sure, if working with real data, **please backup the volumes first**. + ### Basic docker commands ```bash diff --git a/docker-compose.yml b/docker-compose.yml index 45a0747..cfd58c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,9 @@ services: - UPLOADS_FOLDER=/data/uploaded_documents # - LOGS_DIR=/path/to/log - IS_FIRST_RUN=${IS_FIRST_RUN:-false} - - UWAZI_RELEASE_TAG=${UWAZI_RELEASE_TAG:-production} + - RUN_YARN_MIGRATE_REINDEX=${RUN_YARN_MIGRATE_REINDEX:-false} + - UWAZI_GIT_RELEASE_REF=${UWAZI_GIT_RELEASE_REF:-production} + - DB_INITIALIZATION_PATH=${DB_INITIALIZATION_PATH:-/home/node/uwazi/database/blank_state/uwazi_development} volumes: - uploaded_documents:/data/uploaded_documents depends_on: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 05d8e7f..ee4c1ef 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,15 +1,16 @@ #!/bin/bash +DB_INITIALIZATION_PATH="${DB_INITIALIZATION_PATH:-"/home/node/uwazi/dump/uwazi_development"}" +echo "uwazi-docker: UWAZI_GIT_RELEASE_REF: $UWAZI_GIT_RELEASE_REF" echo "uwazi-docker: IS_FIRST_RUN: $IS_FIRST_RUN" +echo "uwazi-docker: RUN_YARN_MIGRATE_REINDEX: $RUN_YARN_MIGRATE_REINDEX" +echo "uwazi-docker: DB_INITIALIZATION_PATH: $DB_INITIALIZATION_PATH" # DB_INITIALIZATION_PATH=/home/node/uwazi/blank_state/uwazi_development -# DB_INITIALIZATION_PATH=/home/node/uwazi/dump/uwazi_development -DB_INITIALIZATION_PATH=/home/node/uwazi/database/blank_state/uwazi_development -set -x -ls -lha /home/node/uwazi/ +# set -x +# ls -lha /home/node/uwazi/ # ls -lha /home/node/uwazi/dump - if [ "$IS_FIRST_RUN" = "true" ] ; then echo "uwazi-docker: Enviroment variable IS_FIRST_RUN is true. Assuming need to install database from blank state" @@ -25,10 +26,19 @@ if [ "$IS_FIRST_RUN" = "true" ] ; then yarn migrate yarn reindex - echo "uwazi-docker: If no fatal errors occurred, you will not need to use this command again" + echo "uwazi-docker: If no fatal errors occurred, you will never need to use this command again" + exit 0 + +elif [ "$RUN_YARN_MIGRATE_REINDEX" = "true" ] ; then + echo "uwazi-docker: Applyng yarn reindex. This will use data from MongoDB to feed Elastic Search" + yarn migrate + yarn reindex + + echo "uwazi-docker: If no fatal errors occurred, you will not need to use this command again unless data needs update to run with newer Uwazi or database version" exit 0 else - echo "uwazi-docker: Enviroment variable IS_FIRST_RUN is not true. Assume MongoDB and Elastic Search provide already are intialized" + echo "uwazi-docker: Enviroment variable IS_FIRST_RUN/RUN_YARN_MIGRATE_REINDEX are not true." + echo "uwazi-docker: Assume MongoDB and Elastic Search provide already are intialized." echo "uwazi-docker: [protip] is possible to initialize (or reset o initial state) MongoDB and Elastic Search with enviroment variable IS_FIRST_RUN=true" fi