Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please upgrade to the ArangoDB Release 3.0.0 #1893

Merged
merged 1 commit into from
Jun 29, 2016
Merged

Please upgrade to the ArangoDB Release 3.0.0 #1893

merged 1 commit into from
Jun 29, 2016

Conversation

ghost
Copy link

@ghost ghost commented Jun 27, 2016

No description provided.

@tianon
Copy link
Member

tianon commented Jun 27, 2016

warning: insecure protocol git:// detected: git://github.com/arangodb/arangodb-docker
diff --git a/arangodb_2.8/Dockerfile b/arangodb_3.0/Dockerfile
similarity index 48%
copy from arangodb_2.8/Dockerfile
copy to arangodb_3.0/Dockerfile
index 336031d..bdeb2eb 100644
--- a/arangodb_2.8/Dockerfile
+++ b/arangodb_3.0/Dockerfile
@@ -1,44 +1,49 @@
 FROM debian:jessie
 MAINTAINER Frank Celler <info@arangodb.com>

-RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B
-
 ENV ARCHITECTURE amd64
-ENV ARANGO_VERSION 2.8.9
-ENV ARANGO_URL https://www.arangodb.com/repositories/arangodb2/Debian_8.0
-ENV ARANGO_PACKAGE arangodb_${ARANGO_VERSION}_${ARCHITECTURE}.deb
+ENV ARANGO_VERSION 3.0.0
+ENV ARANGO_URL https://www.arangodb.com/repositories/arangodb3/Debian_8.0
+ENV ARANGO_PACKAGE arangodb3_${ARANGO_VERSION}_${ARCHITECTURE}.deb
 ENV ARANGO_PACKAGE_URL ${ARANGO_URL}/${ARCHITECTURE}/${ARANGO_PACKAGE}
 ENV ARANGO_SIGNATURE_URL ${ARANGO_PACKAGE_URL}.asc

+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B
+
 RUN apt-get update && \
     apt-get install -y --no-install-recommends \
-        libgoogle-perftools4 \
+        libjemalloc1 \
+   libsnappy1 \
         ca-certificates \
         pwgen \
-        wget \
+        curl \
     && \
-    rm -rf /var/lib/apt/lists/* && \
-    wget ${ARANGO_SIGNATURE_URL} &&       \
-    wget ${ARANGO_PACKAGE_URL} &&         \
+    rm -rf /var/lib/apt/lists/*
+
+RUN mkdir /docker-entrypoint-initdb.d
+
+RUN curl -O ${ARANGO_SIGNATURE_URL} &&       \
+    curl -O ${ARANGO_PACKAGE_URL} &&         \
     gpg --verify ${ARANGO_PACKAGE}.asc && \
-    dpkg -i ${ARANGO_PACKAGE} && \
+    (echo arangodb3 arangodb/password password test | debconf-set-selections) && \
+    (echo arangodb3 arangodb/password_again password test | debconf-set-selections) && \
+    DEBIAN_FRONTEND="noninteractive" dpkg -i ${ARANGO_PACKAGE} && \
+    rm -rf /var/lib/arangodb3/* && \
     sed -ri \
-# https://docs.arangodb.com/ConfigureArango/Arangod.html
+# https://docs.arangodb.com/latest/Manual/Administration/Configuration/Endpoint.html
         -e 's!127\.0\.0\.1!0.0.0.0!g' \
-# https://docs.arangodb.com/ConfigureArango/Logging.html
+# https://docs.arangodb.com/latest/Manual/Administration/Configuration/Logging.html
         -e 's!^(file\s*=).*!\1 -!' \
 # run as arangodb:arangodb
         -e 's!^#\s*uid\s*=.*!uid = arangodb!' \
         -e 's!^#\s*gid\s*=.*!gid = arangodb!' \
-        /etc/arangodb/arangod.conf \
+        /etc/arangodb3/arangod.conf \
     && \
-    apt-get purge -y --auto-remove ca-certificates wget && \
+    DEBIAN_FRONTEND="noninteractive" apt-get purge -y --auto-remove ca-certificates && \
     rm -f ${ARANGO_PACKAGE}*

-RUN chown arangodb:arangodb /var/lib/arangodb && \
-  chown arangodb:arangodb /var/lib/arangodb-apps
 # retain the database directory and the Foxx Application directory
-VOLUME ["/var/lib/arangodb", "/var/lib/arangodb-apps"]
+VOLUME ["/var/lib/arangodb3", "/var/lib/arangodb-apps3"]

 COPY docker-entrypoint.sh /entrypoint.sh

@@ -46,5 +51,4 @@ ENTRYPOINT ["/entrypoint.sh"]

 # standard port
 EXPOSE 8529
-USER arangodb
 CMD ["arangod"]
diff --git a/arangodb_2.8/docker-entrypoint.sh b/arangodb_3.0/docker-entrypoint.sh
similarity index 21%
copy from arangodb_2.8/docker-entrypoint.sh
copy to arangodb_3.0/docker-entrypoint.sh
index e8a5fd1..676f563 100755
--- a/arangodb_2.8/docker-entrypoint.sh
+++ b/arangodb_3.0/docker-entrypoint.sh
@@ -1,12 +1,7 @@
 #!/bin/bash
 set -eo pipefail

-DISABLE_AUTHENTICATION="true"
-
-function rwfail {
-  echo "We seem to not have proper rw access to $1. Please make sure that every mounted volume has full rw access for user arangodb ($(id arangodb))"
-  exit 55
-}
+AUTHENTICATION="true"

 # if command starts with an option, prepend arangod
 if [ "${1:0:1}" = '-' ]; then
@@ -15,47 +10,85 @@ fi


 if [ "$1" = 'arangod' ]; then
-   DATADIR=/var/lib/arangodb
-   
-        # ensure proper uid and gid (for example when volume is mounted from the outside)
-        # do NOT chown or stuff like that. when using shared folders on the mac chown is VERY likely to fail due to docker => vm => host issues
-        touch "$DATADIR"/_rwcheck_$HOSTNAME || rwfail $DATADIR
-        rm "$DATADIR"/_rwcheck_"$HOSTNAME"
-        touch /var/lib/arangodb-apps/_rwcheck_"$HOSTNAME" || rwfail /var/lib/arangodb-apps/
-        rm /var/lib/arangodb-apps/_rwcheck_"$HOSTNAME"
-   if [ ! -f "$DATADIR"/SERVER ]; then
+        mkdir -p /var/lib/arangodb3
+        mkdir -p /var/lib/arangodb3-apps
+        
+        # by doing this here we explicitly break support for mounting volumes from the mac (at least for docker pre 1.11)
+        # but otherwise there will be too many problems like this https://github.com/arangodb/arangodb-docker/issues/23
+        # mysql as well as postgres are doing it exactly like this so stick to this
+        chown -R arangodb /var/lib/arangodb3
+        chown -R arangodb /var/lib/arangodb3-apps
+
+   if [ ! -f /var/lib/arangodb3/SERVER ]; then
        if [ -z "$ARANGO_ROOT_PASSWORD" -a -z "$ARANGO_NO_AUTH" -a -z "$ARANGO_RANDOM_ROOT_PASSWORD" ]; then
            echo >&2 'error: database is uninitialized and password option is not specified '
            echo >&2 '  You need to specify one of $ARANGO_ROOT_PASSWORD, $ARANGO_NO_AUTH and $ARANGO_RANDOM_ROOT_PASSWORD'
            exit 1
        fi

-                echo "Initializing database...Hang on..."
                 if [ ! -z "$ARANGO_RANDOM_ROOT_PASSWORD" ]; then
-                  ARANGO_ROOT_PASSWORD=$(pwgen -s -1 16)
-                  echo "==========================================="
-                  echo "GENERATED ROOT PASSWORD: $ARANGO_ROOT_PASSWORD"
-                  echo "==========================================="
+                   ARANGO_ROOT_PASSWORD=$(pwgen -s -1 16)
+                   echo "==========================================="
+                   echo "GENERATED ROOT PASSWORD: $ARANGO_ROOT_PASSWORD"
+                   echo "==========================================="
                 fi

-                if [ ! -z "$ARANGO_ROOT_PASSWORD" ]; then
-                  (
-                    echo "require(\"org/arangodb/users\").replace(\"root\", \"$ARANGO_ROOT_PASSWORD\");"
-                  ) |
-                  /usr/sbin/arangod --console --log.tty "" &> /dev/null
-                  DISABLE_AUTHENTICATION="false"
+       if [ ! -z "$ARANGO_ROOT_PASSWORD" ]; then
+                   echo "Initializing root user...Hang on..."
+                   ARANGODB_DEFAULT_ROOT_PASSWORD="$ARANGO_ROOT_PASSWORD" /usr/sbin/arango-init-database || true
                 fi
-                # Initialize if not already done
-                /usr/sbin/arangod --console --upgrade
+
+                echo "Initializing database...Hang on..."
+
+                arangod --server.authentication false \
+            --server.endpoint=tcp://127.0.0.1:8529 \
+            --log.file /tmp/init-log \
+            --log.foreground-tty false &
+       pid="$!"
+
+       counter=0
+       ARANGO_UP=0
+       while [ "$ARANGO_UP" = "0" ];do
+           if [ $counter -gt 0 ];then
+           sleep 1
+           fi
+
+           if [ "$counter" -gt 100 ];then
+           echo "ArangoDB didn't start correctly during init"
+           cat /tmp/init-log
+           exit 1
+           fi
+           let counter=counter+1
+           ARANGO_UP=1
+           curl -s localhost:8529/_api/version &>/dev/null || ARANGO_UP=0
+       done
+
+       for f in /docker-entrypoint-initdb.d/*; do
+           case "$f" in
+               *.sh)     echo "$0: running $f"; . "$f" ;;
+               *.js)     echo "$0: running $f"; arangosh --javascript.execute "$f" ;;
+               */dumps)    echo "$0: restoring databases"; for d in $f/*; do echo "restoring $d";arangorestore --server.endpoint=tcp://127.0.0.1:8529 --create-database true --include-system-collections true --input-directory $d; done; echo ;;
+           esac
+       done
+
+       if ! kill -s TERM "$pid" || ! wait "$pid"; then
+                  echo >&2 'ArangoDB Init failed.'
+                  exit 1
+       fi
+
+                echo "Database initialized...Starting System..."
+   fi
+
+   # if we really want to start arangod and not bash or any other thing
+   # prepend --authentication as the FIRST argument
+   # (so it is overridable via command line as well)
+   shift
+
+   if [ ! -z "$ARANGO_NO_AUTH" ]; then
+       AUTHENTICATION="false"
    fi
-fi

-if [ "$1" == "arangod" ]; then
-  # if we really want to start arangod and not bash or any other thing
-  # prepend --disable-authentication as the FIRST argument
-  # (so it is overridable via command line as well)
-  shift
-  set -- arangod --server.disable-authentication="$DISABLE_AUTHENTICATION" "$@"
+   set -- arangod --server.authentication="$AUTHENTICATION" "$@"
 fi

 exec "$@"

@tianon
Copy link
Member

tianon commented Jun 27, 2016

It might be easier to review those entrypoint.sh changes via arangodb/arangodb-docker@b29a6ff...e1f1dd4#diff-22b10e4e7d3760d9288d1e8cead8be9a (GitHub highlights the whitespace changes, which helps a bit)

Was the VOLUME path change intentional?

@m0ppers
Copy link
Contributor

m0ppers commented Jun 28, 2016

yes this was intentional...you cannot upgrade arangodb 2.8 to 3.0 straight away...you must dump and reimport...so we changed the default path in our dpkg to /var/lib/arangodb3 to avoid any conflicts or corrupted data...does that make sense?

@yosifkit
Copy link
Member

LGTM, Build test of #1893; 10fedd4 (arangodb):

$ bashbrew build arangodb:2.5.5
Using bashbrew/cache:f29536db263c0dc758e6dc212f6f67e83556e5112802a316961f5869bea40e5e (arangodb:2.5.5)
Tagging arangodb:2.5.5
Tagging arangodb:2.5

$ test/run.sh arangodb:2.5.5
testing arangodb:2.5.5
    'utc' [1/4]...passed
    'cve-2014--shellshock' [2/4]...passed
    'no-hard-coded-passwords' [3/4]...passed
    'override-cmd' [4/4]...passed


$ bashbrew build arangodb:2.6
Using bashbrew/cache:f0651c72e5be44786b7ab2551424c2b32bb959eab9afcb21979a4c3c7820acea (arangodb:2.6)
Tagging arangodb:2.6
Tagging arangodb:2.6.10

$ test/run.sh arangodb:2.6
testing arangodb:2.6
    'utc' [1/4]...passed
    'cve-2014--shellshock' [2/4]...passed
    'no-hard-coded-passwords' [3/4]...passed
    'override-cmd' [4/4]...passed


$ bashbrew build arangodb:2.7
Using bashbrew/cache:92ec1ff7fce9f9e6c91f7c9b250886e6c3ab162ea9ff3581b138168fc81797fc (arangodb:2.7)
Tagging arangodb:2.7
Tagging arangodb:2.7.5

$ test/run.sh arangodb:2.7
testing arangodb:2.7
    'utc' [1/4]...passed
    'cve-2014--shellshock' [2/4]...passed
    'no-hard-coded-passwords' [3/4]...passed
    'override-cmd' [4/4]...passed


$ bashbrew build arangodb:2.8
Using bashbrew/cache:129cfd8d70406124b75a1118fee4ddf0b8b167bc4718bf769fff24f223fdbfcb (arangodb:2.8)
Tagging arangodb:2.8
Tagging arangodb:2.8.9

$ test/run.sh arangodb:2.8
testing arangodb:2.8
    'utc' [1/4]...passed
    'cve-2014--shellshock' [2/4]...passed
    'no-hard-coded-passwords' [3/4]...passed
    'override-cmd' [4/4]...passed


$ bashbrew build arangodb:3.0
warning: insecure protocol git:// detected: git://github.com/arangodb/arangodb-docker
Building bashbrew/cache:e615a55240ea55eddcedbac1d7becfbde76d3caf8520fb169308054ce4de15cf (arangodb:3.0)
Tagging arangodb:3.0
Tagging arangodb:3.0.0
Tagging arangodb:latest

$ test/run.sh arangodb:3.0
testing arangodb:3.0
    'utc' [1/4]...passed
    'cve-2014--shellshock' [2/4]...passed
    'no-hard-coded-passwords' [3/4]...passed
    'override-cmd' [4/4]...passed

@yosifkit
Copy link
Member

Can you make a docs PR to update the persistent data section?

@yosifkit yosifkit merged commit fdb9762 into docker-library:master Jun 29, 2016
@m0ppers
Copy link
Contributor

m0ppers commented Jun 30, 2016

thanks for pointing that out. pull request incoming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants