Skip to content

Commit

Permalink
arangodb 3.10.14
Browse files Browse the repository at this point in the history
  • Loading branch information
KVS85 committed Apr 5, 2024
1 parent c507e87 commit 7b5dbaf
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 0 deletions.
59 changes: 59 additions & 0 deletions alpine/3.10.14/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM alpine:3.16
MAINTAINER Frank Celler <[email protected]>

ENV ARANGO_VERSION 3.10.14

# see
# https://docs.arangodb.com/3.10/components/arangodb-server/options/#--serverendpoint
# https://docs.arangodb.com/3.10/components/arangodb-server/options/#log

RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools nodejs yarn && \
yarn global add [email protected] && \
apk del yarn && \
gpg --batch --keyserver keys.openpgp.org --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B && \
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/arangodb310/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 /usr/bin/foxx && \
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
COPY docker-foxx.sh /usr/bin/foxx

ENTRYPOINT ["/entrypoint.sh"]

# standard port
EXPOSE 8529
CMD ["arangod"]
181 changes: 181 additions & 0 deletions alpine/3.10.14/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#!/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

if [ "$(id -u)" = "0" ] ; then
foxx server set default http://127.0.0.1:$ARANGO_INIT_PORT
else
echo Not setting foxx server default because we are not root.
fi

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 [ "$(id -u)" = "0" ] ; then
foxx server remove default
fi

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 "$@"
4 changes: 4 additions & 0 deletions alpine/3.10.14/docker-foxx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
test -d /tmp/foxx || mkdir -m 700 /tmp/foxx
export HOME=/tmp/foxx
exec /usr/local/share/.config/yarn/global/node_modules/.bin/foxx "$@"

0 comments on commit 7b5dbaf

Please sign in to comment.