Skip to content

Commit

Permalink
#45, #43: new options: UWAZI_GIT_RELEASE_REF, RUN_YARN_MIGRATE_REINDE…
Browse files Browse the repository at this point in the history
…X, DB_INITIALIZATION_PATH
  • Loading branch information
fititnt committed Jul 10, 2023
1 parent 841a972 commit c12681d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM node:18-bullseye
LABEL maintainer="Emerson Rocha <[email protected]>"

ARG UWAZI_GIT_RELEASE_REF=production

# see https://github.com/nodejs/docker-node#how-to-use-this-image

## Install common software
Expand All @@ -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 \
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 17 additions & 7 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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

Expand Down

0 comments on commit c12681d

Please sign in to comment.