diff --git a/Dockerfile b/Dockerfile index 1197ec4..959b432 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,33 +9,23 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ dh-autoreconf \ git \ libpng-dev \ - libcurl3 \ - openssl \ + gnupg \ poppler-utils -RUN curl -fsSL https://pgp.mongodb.com/server-4.2.asc | \ - gpg -o /usr/share/keyrings/mongodb-server-4.2.gpg \ - --dearmor - -RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-4.2.gpg ] http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list -RUN apt-get update -# RUN apt-get install -y mongodb-org-shell mongodb-org-tools -RUN apt-get install -y mongodb-org-tools -RUN apt-get clean && rm -rf /var/lib/apt/lists/* - # Install mongo & mongorestore (this is used only for database initialization, not on runtime) # So much space need, see 'After this operation, 184 MB of additional disk space will be used.' -# RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 20691EEC35216C63CAF66CE1656408E390CFB1F5 \ -# && echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \ -# RUN echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \ -# && apt-get update \ -# && apt-get install -y mongodb-org-shell mongodb-org-tools \ -# && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \ + gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \ + --dearmor + +RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" \ + | tee /etc/apt/sources.list.d/mongodb-org-6.0.list \ + && apt-get update \ + && apt-get install -y mongodb-mongosh mongodb-org-tools \ + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* -# ## Download Uwazi v1.4 -# RUN git clone -b v1.4 --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ -## Download Uwazi v1.4 RUN git clone -b production --single-branch --depth=1 https://github.com/huridocs/uwazi.git /home/node/uwazi/ \ && chown node:node -R /home/node/uwazi/ \ && cd /home/node/uwazi/ \ diff --git a/README.md b/README.md index f7e6be7..758a8cc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ for building and sharing document collections. See also [History of Uwazi](https://github.com/huridocs/uwazi/wiki/History-of-Uwazi). ## Usage -The uwazi-docker requires docker-compose installed. See +The uwazi-docker requires docker compose installed. See [requirements](requirements.md). If you are a developer, can also check some advanced information on [development-instructions.md](development-instructions.md) and a draft of [production-instructions.md](production-instructions.md). @@ -31,15 +31,15 @@ Run these commands on your terminal **only** the first time: ```bash git clone https://github.com/fititnt/uwazi-docker.git cd uwazi-docker -docker-compose run -e IS_FIRST_RUN=true --rm uwazi # Install/Re-install from empty data +docker compose run -e IS_FIRST_RUN=true --rm uwazi # Install/Re-install from empty data ``` - + ### Run ```bash -docker-compose up -d uwazi # Run uwazi on background (automatic restart on reboot unless stopped) +docker compose up -d uwazi # Run uwazi on background (automatic restart on reboot unless stopped) ``` Open your browser at . Initial user: _admin_, password: _admin_. @@ -48,13 +48,13 @@ Open your browser at . Initial user: _admin_, password: ```bash # Stop all containers from this uwazi-docker and do not restart again until you explicit ask for it -docker-compose stop +docker compose stop # Using "-d" param to run uwazi and its dependencies on background -docker-compose up -d uwazi +docker compose up -d uwazi # No "-d" param, start uwazi, MongoDB & Elastic Search and see what is happening inside the containers -docker-compose up uwazi +docker compose up uwazi # See what containers are running now docker ps @@ -66,10 +66,10 @@ docker volume ls docker volume ls | grep 'mongodb_data1\|uploaded_documents' # Want some GUI to see what is happening on MongoDB? Use nosqlclient -docker-compose up -d mongo-gui-mongoclient +docker compose up -d mongo-gui-mongoclient # Want some GUI to see what is happening on Elastic Search? Try Dejavu -docker-compose up -d elasticsearch-gui-dejavu +docker compose up -d elasticsearch-gui-dejavu ``` ### Extra features @@ -77,7 +77,7 @@ docker-compose up -d elasticsearch-gui-dejavu #### Want some GUI to see what is happening on MongoDB? Use nosqlclient ```bash -docker-compose up -d mongo-gui-mongoclient +docker compose up -d mongo-gui-mongoclient ``` By default, uses . @@ -85,7 +85,7 @@ By default, uses . #### Want some GUI to see what is happening on Elastic Search? Try Dejavu ```bash -docker-compose up -d elasticsearch-gui-dejavu +docker compose up -d elasticsearch-gui-dejavu ``` By default, uses . @@ -110,14 +110,14 @@ instead of Public Domain unlicense. # Tests on Ubuntu 20.04 LTS - fititnt@bravo:/workspace/git/fititnt/uwazi-docker$ docker compose --file /workspace/git/fititnt/uwazi-docker/docker-compose.yml run -e IS_FIRST_RUN=true --rm uwazi - stat /workspace/git/fititnt/uwazi-docker/docker-compose.yml: no such file or directory - fititnt@bravo:/workspace/git/fititnt/uwazi-docker$ docker compose --file docker-compose.yml run -e IS_FIRST_RUN=true --rm uwazi - stat /var/lib/snapd/void/docker-compose.yml: no such file or directory + fititnt@bravo:/workspace/git/fititnt/uwazi-docker$ docker compose --file /workspace/git/fititnt/uwazi-docker/docker compose.yml run -e IS_FIRST_RUN=true --rm uwazi + stat /workspace/git/fititnt/uwazi-docker/docker compose.yml: no such file or directory + fititnt@bravo:/workspace/git/fititnt/uwazi-docker$ docker compose --file docker compose.yml run -e IS_FIRST_RUN=true --rm uwazi + stat /var/lib/snapd/void/docker compose.yml: no such file or directory fititnt@bravo:~/Downloads/uwazi-docker$ sudo su [sudo] password for fititnt: - root@bravo:/home/fititnt/Downloads/uwazi-docker# docker compose --file docker-compose.yml run -e IS_FIRST_RUN=true --rm uwazi + root@bravo:/home/fititnt/Downloads/uwazi-docker# docker compose --file docker compose.yml run -e IS_FIRST_RUN=true --rm uwazi Logs (...) @@ -142,10 +142,18 @@ instead of Public Domain unlicense. # Refrech -docker compose --file docker-compose.yml run -e IS_FIRST_RUN=true --rm uwazi +docker compose --file docker compose.yml run -e IS_FIRST_RUN=true --rm uwazi +# (...) +docker stop $(docker ps -a -q) +docker system prune --all + +# debug containers +docker ps +docker logs --tail 50 --follow --timestamps uwazi-docker-mongo-1 +docker logs --tail 50 --follow --timestamps uwazi-docker-elasticsearch-1 -# ... -docker system prune --all +### +git clone -b production --single-branch --depth=1 https://github.com/huridocs/uwazi.git huridocs-uwazi-docker/ --> \ No newline at end of file diff --git a/development-instructions.md b/development-instructions.md index 5047c10..632fcc7 100644 --- a/development-instructions.md +++ b/development-instructions.md @@ -44,21 +44,21 @@ tabs. ```bash # To run and see messages -docker-compose up elasticsearch mongo +docker compose up elasticsearch mongo # To run on background use -d param -docker-compose up -d elasticsearch mongo +docker compose up -d elasticsearch mongo # Stop all containers from uwazi-docker after they where not more need and # avoid they stay running even after you reboot your operational system -docker-compose down +docker compose down ``` The following step is optional if you want to populate the databases not using uwazi-docker. ```bash -docker-compose run -e IS_FIRST_RUN=true --rm uwazi +docker compose run -e IS_FIRST_RUN=true --rm uwazi ``` ## Create your own repository @@ -143,17 +143,17 @@ local development machine. **9300/tcp** means the same container have the port ```bash # See log messages of Mongo and Elastic Search -docker-compose logs -f mongo elasticsearch +docker compose logs -f mongo elasticsearch # Want some GUI to see what is happening on MongoDB? Use nosqlclient -docker-compose up -d mongo-gui-mongoclient +docker compose up -d mongo-gui-mongoclient # Want some GUI to see what is happening on Elastic Search? Try Dejavu -docker-compose up -d elasticsearch-gui-dejavu +docker compose up -d elasticsearch-gui-dejavu ``` ### Configure ports of Mongo and Elastic Search -At this point, you have to edit the file [docker-compose.yml](docker-compose.yml) +At this point, you have to edit the file [docker compose.yml](docker compose.yml) and edit the hardcored values. Protip: the most common error of using uwazi-docker with Uwazi a port is already diff --git a/docker-compose.yml b/docker-compose.yml index 47917a0..9b086e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ 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} volumes: - uploaded_documents:/data/uploaded_documents depends_on: @@ -28,7 +29,7 @@ services: environment: - cluster.name=docker-cluster - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false + # - xpack.security.enabled=false ulimits: memlock: soft: -1 @@ -55,12 +56,15 @@ services: mongo: # image: mongo:3.4 # Based on https://github.com/huridocs/uwazi/releases/tag/1.123.2 . Please update this part in future - image: mongo:4.2 + # image: mongo:4.2 + # Using mongo 6.0 (not 4.2 as suggested by Uwazi 1.123.2) because mongo-shell on 4.2 don't run on Debian bullseye + image: mongo:6.0 restart: unless-stopped volumes: # - ./data/mongo:/data/db - mongodb_data1:/data/db - command: mongod --smallfiles + command: mongod + # command: mongod --smallfiles # Don't publish unprotected mongod # ports: # - 27017:27017 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7b21fab..e7aaa88 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,16 +1,24 @@ -#!/bin/sh +#!/bin/bash echo "uwazi-docker: IS_FIRST_RUN: $IS_FIRST_RUN" -DB_INITIALIZATION_PATH=/home/node/uwazi/blank_state/uwazi_development +# 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/ +# 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" - echo "\n\nuwazi-docker: Deleting ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database" - mongo -host ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} --eval "db.dropDatabase()" + echo "uwazi-docker: Deleting ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database" + # mongo -host ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} --eval "db.dropDatabase()" + mongosh -host "${DBHOST:-mongo}" "${DATABASE_NAME:-uwazi_development}" --eval "db.dropDatabase()" - echo "\n\nuwazi-docker: Importing $DB_INITIALIZATION_PATH to ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database" - mongorestore -h ${DBHOST:-mongo} $DB_INITIALIZATION_PATH --db=${DATABASE_NAME:-uwazi_development} + echo "uwazi-docker: Importing $DB_INITIALIZATION_PATH to ${DBHOST:-mongo} ${DATABASE_NAME:-uwazi_development} MongoDB database" + mongorestore -h "${DBHOST:-mongo}" "$DB_INITIALIZATION_PATH" --db="${DATABASE_NAME:-uwazi_development}" echo "uwazi-docker: Applyng yarn reindex. This will use data from MongoDB to feed Elastic Search" yarn reindex diff --git a/requirements.md b/requirements.md index 9c4fd16..a4e5764 100644 --- a/requirements.md +++ b/requirements.md @@ -19,4 +19,4 @@ TODO: write about (fititnt, 2018-04-18 04:47 BRT) ### Docker [See updated instructions about how to install Docker Engine on Windows, Mac and Linux](https://docs.docker.com/compose/install/). -Docker docker-compose is already installed. \ No newline at end of file +Docker docker compose is already installed. \ No newline at end of file diff --git a/uninstall.md b/uninstall.md index 17ef3bc..53d4eb3 100644 --- a/uninstall.md +++ b/uninstall.md @@ -4,11 +4,11 @@ These commands explain how to uninstall uwazi-docker. ## Uninstall -Use [docker-compose down](https://docs.docker.com/compose/reference/down/) to +Use [docker compose down](https://docs.docker.com/compose/reference/down/) to remove the containers and networks created by uwazi-docker. This will not delete the data created. -`docker-compose down # clean only containers and networks` +`docker compose down # clean only containers and networks` ## Complete Uninstall @@ -20,6 +20,6 @@ more the uwazi-docker or want a really full reinstall (e.g. is debugging). ```bash -# Remove containers, networks and volumes created by uwazi-docker docker-compose up -docker-compose down -v --rmi all --remove-orphans # WARNING: Purge everything, even data +# Remove containers, networks and volumes created by uwazi-docker docker compose up +docker compose down -v --rmi all --remove-orphans # WARNING: Purge everything, even data ``` \ No newline at end of file