diff --git a/HISTORY.rst b/HISTORY.rst index 48fe8e7409..6235359143 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -74,6 +74,10 @@ - Unify all line endings to be Linux style. - Add support for changing the system messages position. GitLab issue #640. Thanks to Matthias Urhahn (@d4rken). +- Update Docker deploy script. Use alpine postgres version. + Support Docker networks and make it the default. + Delete the containers to allow the script to be idempotent. + 3.2.8 (2019-10-01) ================== @@ -528,8 +532,6 @@ - Add workflow actions to grant or remove permissions to a document. - Add support for locked files for watchfolder. -<<<<<<< HEAD -======= 3.1.11 (2019-04-XX) =================== diff --git a/contrib/scripts/install/docker.sh b/contrib/scripts/install/docker.sh index 8e851725ca..80cbf0ae4e 100755 --- a/contrib/scripts/install/docker.sh +++ b/contrib/scripts/install/docker.sh @@ -5,18 +5,19 @@ set -e # $ curl -fsSL get.mayan-edms.com -o get-mayan-edms.sh # $ sh get-mayan-edms.sh # -# NOTE: Make sure to verify the contents of the script +# NOTE: Before executing, make sure to verify the contents of the script # you downloaded matches the contents of docker.sh # located at https://gitlab.com/mayan-edms/mayan-edms/blob/master/contrib/scripts/install/docker.sh -# before executing. : ${VERBOSE:=true} : ${INSTALL_DOCKER:=false} : ${DELETE_VOLUMES:=false} +: ${USE_DOCKER_NETWORK:=true} +: ${DOCKER_NETWORK_NAME:=mayan} : ${DATABASE_USER:=mayan} : ${DATABASE_NAME:=mayan} : ${DATABASE_PASSWORD:=mayanuserpass} -: ${DOCKER_POSTGRES_IMAGE:=postgres:9.6} +: ${DOCKER_POSTGRES_IMAGE:=postgres:9.6-alpine} : ${DOCKER_POSTGRES_CONTAINER:=mayan-edms-postgres} : ${DOCKER_POSTGRES_VOLUME:=/docker-volumes/mayan-edms/postgres} : ${DOCKER_POSTGRES_PORT:=5432} @@ -44,6 +45,8 @@ echo "Variable values to be used:" echo "---------------------------" echo "INSTALL_DOCKER: $INSTALL_DOCKER" echo "DELETE_VOLUMES: $DELETE_VOLUMES" +echo "USE_DOCKER_NETWORK: $USE_DOCKER_NETWORK" +echo "DOCKER_NETWORK_NAME: $DOCKER_NETWORK_NAME" echo "DATABASE_USER: $DATABASE_USER" echo "DATABASE_NAME: $DATABASE_NAME" echo "DATABASE_PASSWORD: $DATABASE_PASSWORD" @@ -54,7 +57,11 @@ echo "DOCKER_POSTGRES_PORT: $DOCKER_POSTGRES_PORT" echo "DOCKER_MAYAN_IMAGE: $DOCKER_MAYAN_IMAGE" echo "DOCKER_MAYAN_CONTAINER: $DOCKER_MAYAN_CONTAINER" echo "DOCKER_MAYAN_VOLUME: $DOCKER_MAYAN_VOLUME" -echo "\nStarting in 10 seconds." +echo +echo "Override any of them by setting them before the script. " +echo "Example: INSTALL_DOCKER=true sh get-mayan-edms.sh" + +echo "\nStarting in 10 seconds. Press CTRL+C to cancel." sleep 10 fi @@ -86,19 +93,41 @@ true || rm DOCKER_POSTGRES_VOLUME -Rf echo "Done" fi -echo -n "* Pulling (downloading) the Mayan EDMS Docker image..." -docker pull $DOCKER_MAYAN_IMAGE >/dev/null -echo "Done" - echo -n "* Pulling (downloading) the PostgreSQL Docker image..." docker pull $DOCKER_POSTGRES_IMAGE > /dev/null echo "Done" +echo -n "* Pulling (downloading) the Mayan EDMS Docker image..." +docker pull $DOCKER_MAYAN_IMAGE >/dev/null +echo "Done" + +if [ "$USE_DOCKER_NETWORK" = true ]; then + echo -n "* Creating Docker network..." + docker network create $DOCKER_NETWORK_NAME 2> /dev/null || true + # Ignore error if the network already exists + echo "Done" +fi + +if [ "$USE_DOCKER_NETWORK" = true ]; then + NETWORK_ARGUMENT="--network=$DOCKER_NETWORK_NAME" + POSTGRES_PORT_ARGUMENT="" + MAYAN_DATABASE_PORT_ARGUMENT="" + MAYAN_DATABASE_HOST_ARGUMENT="-e MAYAN_DATABASE_HOST=$DOCKER_POSTGRES_CONTAINER" +else + NETWORK_ARGUMENT="" + POSTGRES_PORT_ARGUMENT="-e $DOCKER_POSTGRES_PORT:5432" + MAYAN_DATABASE_PORT_ARGUMENT="-e MAYAN_DATABASE_PORT=$DOCKER_POSTGRES_PORT" + MAYAN_DATABASE_HOST_ARGUMENT="-e MAYAN_DATABASE_HOST=172.17.0.1" +fi + +docker rm -f $DOCKER_POSTGRES_CONTAINER >/dev/null 2>&1 || true + echo -n "* Deploying the PostgreSQL container..." docker run -d \ --name $DOCKER_POSTGRES_CONTAINER \ +$NETWORK_ARGUMENT \ --restart=always \ --p $DOCKER_POSTGRES_PORT:5432 \ +$POSTGRES_PORT_ARGUMENT \ -e POSTGRES_USER=$DATABASE_USER \ -e POSTGRES_DB=$DATABASE_NAME \ -e POSTGRES_PASSWORD=$DATABASE_PASSWORD \ @@ -110,17 +139,20 @@ echo -n "* Waiting for the PostgreSQL container to be ready (10 seconds)..." sleep 10 echo "Done" +docker rm -f $DOCKER_MAYAN_CONTAINER >/dev/null 2>&1 || true + echo -n "* Deploying Mayan EDMS container..." docker run -d \ --name $DOCKER_MAYAN_CONTAINER \ +$NETWORK_ARGUMENT \ --restart=always \ -p 80:8000 \ -e MAYAN_DATABASE_ENGINE=django.db.backends.postgresql \ --e MAYAN_DATABASE_HOST=172.17.0.1 \ +$MAYAN_DATABASE_HOST_ARGUMENT \ +$MAYAN_DATABASE_PORT_ARGUMENT \ -e MAYAN_DATABASE_NAME=$DATABASE_NAME \ -e MAYAN_DATABASE_PASSWORD=$DATABASE_PASSWORD \ -e MAYAN_DATABASE_USER=$DATABASE_USER \ --e MAYAN_DATABASE_PORT=$DOCKER_POSTGRES_PORT \ -e MAYAN_DATABASE_CONN_MAX_AGE=0 \ -v $DOCKER_MAYAN_VOLUME:/var/lib/mayan \ $DOCKER_MAYAN_IMAGE >/dev/null