From c507e8709115419c988f47f735f72a4d95538131 Mon Sep 17 00:00:00 2001 From: Vadim Kondratev Date: Mon, 25 Mar 2024 14:36:57 +0100 Subject: [PATCH] arangodb 3.12.0 --- alpine/3.12.0/Dockerfile | 55 ++++++++++ alpine/3.12.0/docker-entrypoint.sh | 171 +++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 alpine/3.12.0/Dockerfile create mode 100755 alpine/3.12.0/docker-entrypoint.sh diff --git a/alpine/3.12.0/Dockerfile b/alpine/3.12.0/Dockerfile new file mode 100644 index 00000000..b5884803 --- /dev/null +++ b/alpine/3.12.0/Dockerfile @@ -0,0 +1,55 @@ +FROM alpine:3.17 +MAINTAINER Frank Celler + +ENV ARANGO_VERSION 3.12.0 + +# see +# https://docs.arangodb.com/3.12/components/arangodb-server/options/#--serverendpoint +# https://docs.arangodb.com/3.12/components/arangodb-server/options/#log + +RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools && \ + gpg --batch --keyserver keys.openpgp.org --recv-keys 8003EDF6F05459984878D4A6C04AD0FD86FEC04D && \ + mkdir /docker-entrypoint-initdb.d && \ + cd /tmp && \ + arch="$(apk --print-arch)" && \ + case "$arch" in \ + x86_64) dpkgArch='amd64' ;; \ + aarch64) dpkgArch='arm64' ;; \ + *) echo >&2 "unsupported: $arch" && exit 1 ;; \ + esac && \ + ARANGO_URL="https://download.arangodb.com/arangodb312/DEBIAN/$dpkgArch" && \ + ARANGO_PACKAGE="arangodb3_${ARANGO_VERSION}-1_${dpkgArch}.deb" && \ + ARANGO_PACKAGE_URL="${ARANGO_URL}/${ARANGO_PACKAGE}" && \ + ARANGO_SIGNATURE_URL="${ARANGO_PACKAGE_URL}.asc" && \ + wget ${ARANGO_SIGNATURE_URL} && \ + wget ${ARANGO_PACKAGE_URL} && \ + gpg --verify ${ARANGO_PACKAGE}.asc && \ + ar x ${ARANGO_PACKAGE} data.tar.gz && \ + tar -C / -x -z -f data.tar.gz && \ + sed -ri \ + -e 's!127\.0\.0\.1!0.0.0.0!g' \ + -e 's!^(file\s*=\s*).*!\1 -!' \ + -e 's!^\s*uid\s*=.*!!' \ + /etc/arangodb3/arangod.conf && \ + chgrp -R 0 /var/lib/arangodb3 /var/lib/arangodb3-apps && \ + chmod -R 775 /var/lib/arangodb3 /var/lib/arangodb3-apps && \ + rm -f ${ARANGO_PACKAGE}* data.tar.gz && \ + apk del gnupg +# Note that Openshift runs containers by default with a random UID and GID 0. +# We need that the database and apps directory are writable for this config. + +ENV GLIBCXX_FORCE_NEW=1 + +# Adjust TZ by default since tzdata package isn't present (BTS-913) +RUN echo "UTC" > /etc/timezone + +# retain the database directory and the Foxx Application directory +VOLUME ["/var/lib/arangodb3", "/var/lib/arangodb3-apps"] + +COPY docker-entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + +# standard port +EXPOSE 8529 +CMD ["arangod"] diff --git a/alpine/3.12.0/docker-entrypoint.sh b/alpine/3.12.0/docker-entrypoint.sh new file mode 100755 index 00000000..93223c68 --- /dev/null +++ b/alpine/3.12.0/docker-entrypoint.sh @@ -0,0 +1,171 @@ +#!/bin/sh +set -e + +if [ -z "$ARANGO_INIT_PORT" ] ; then + ARANGO_INIT_PORT=8999 +fi + +AUTHENTICATION="true" + +# if command starts with an option, prepend arangod +case "$1" in + -*) set -- arangod "$@" ;; + *) ;; +esac + +# check for numa +NUMACTL="" + +if [ -d /sys/devices/system/node/node1 -a -f /proc/self/numa_maps ]; then + if [ "$NUMA" = "" ]; then + NUMACTL="numactl --interleave=all" + elif [ "$NUMA" != "disable" ]; then + NUMACTL="numactl --interleave=$NUMA" + fi + + if [ "$NUMACTL" != "" ]; then + if $NUMACTL echo > /dev/null 2>&1; then + echo "using NUMA $NUMACTL" + else + echo "cannot start with NUMA $NUMACTL: please ensure that docker is running with --cap-add SYS_NICE" + NUMACTL="" + fi + fi +fi + +if [ "$1" = 'arangod' ]; then + # /var/lib/arangodb3 and /var/lib/arangodb3-apps must exist and + # be writable by the user under which we run the container. + + # Make a copy of the configuration file to patch it, note that this + # must work regardless under which user we run: + cp /etc/arangodb3/arangod.conf /tmp/arangod.conf + + ARANGO_STORAGE_ENGINE=rocksdb + if [ ! -z "$ARANGO_ENCRYPTION_KEYFILE" ]; then + echo "Using encrypted database" + sed -i /tmp/arangod.conf -e "s;^.*encryption-keyfile.*;encryption-keyfile=$ARANGO_ENCRYPTION_KEYFILE;" + fi + + if [ ! -f /var/lib/arangodb3/SERVER ] && [ "$SKIP_DATABASE_INIT" != "1" ]; then + if [ ! -z "$ARANGO_ROOT_PASSWORD_FILE" ]; then + if [ -f "$ARANGO_ROOT_PASSWORD_FILE" ]; then + ARANGO_ROOT_PASSWORD="$(cat $ARANGO_ROOT_PASSWORD_FILE)" + else + echo "WARNING: password file '$ARANGO_ROOT_PASSWORD_FILE' does not exist" + fi + fi + # Please note that the +x in the following line is for the case + # that ARANGO_ROOT_PASSWORD is set but to an empty value, please + # do not remove! + if [ -z "${ARANGO_ROOT_PASSWORD+x}" ] && [ -z "$ARANGO_NO_AUTH" ] && [ -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_ROOT_PASSWORD_FILE, ARANGO_NO_AUTH and ARANGO_RANDOM_ROOT_PASSWORD" + exit 1 + fi + + if [ ! -z "$ARANGO_RANDOM_ROOT_PASSWORD" ]; then + ARANGO_ROOT_PASSWORD=$(pwgen -s -1 16) + echo "===========================================" + echo "GENERATED ROOT PASSWORD: $ARANGO_ROOT_PASSWORD" + echo "===========================================" + fi + + if [ ! -z "${ARANGO_ROOT_PASSWORD+x}" ]; then + echo "Initializing root user...Hang on..." + ARANGODB_DEFAULT_ROOT_PASSWORD="$ARANGO_ROOT_PASSWORD" /usr/sbin/arango-init-database -c /tmp/arangod.conf --server.rest-server false --log.level error --database.init-database true || true + export ARANGO_ROOT_PASSWORD + + if [ ! -z "${ARANGO_ROOT_PASSWORD}" ]; then + ARANGOSH_ARGS=" --server.password ${ARANGO_ROOT_PASSWORD} " + fi + else + ARANGOSH_ARGS=" --server.authentication false" + fi + + echo "Initializing database...Hang on..." + + $NUMACTL arangod --config /tmp/arangod.conf \ + --server.endpoint tcp://127.0.0.1:$ARANGO_INIT_PORT \ + --server.authentication false \ + --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 + + $NUMACTL arangosh \ + --server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \ + --server.authentication false \ + --javascript.execute-string "db._version()" \ + > /dev/null 2>&1 || 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" + $NUMACTL arangosh ${ARANGOSH_ARGS} \ + --server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \ + --javascript.execute "$f" + ;; + */dumps) + echo "$0: restoring databases" + for d in $f/*; do + DBName=$(echo ${d}|sed "s;$f/;;") + echo "restoring $d into ${DBName}"; + $NUMACTL arangorestore \ + ${ARANGOSH_ARGS} \ + --server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \ + --create-database true \ + --include-system-collections true \ + --server.database "$DBName" \ + --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 + + set -- arangod "$@" --server.authentication="$AUTHENTICATION" --config /tmp/arangod.conf +else + NUMACTL="" +fi + +exec $NUMACTL "$@"