Skip to content

Commit 1c66350

Browse files
committed
arangodb 3.12.4
1 parent de481d8 commit 1c66350

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

alpine/3.12.4/Dockerfile

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM alpine:3.21
2+
MAINTAINER Frank Celler <[email protected]>
3+
4+
ENV ARANGO_VERSION 3.12.4
5+
6+
# see
7+
# https://docs.arangodb.com/3.12/components/arangodb-server/options/#--serverendpoint
8+
# https://docs.arangodb.com/3.12/components/arangodb-server/options/#log
9+
10+
RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools && \
11+
gpg --batch --keyserver keys.openpgp.org --recv-keys 8003EDF6F05459984878D4A6C04AD0FD86FEC04D && \
12+
mkdir /docker-entrypoint-initdb.d && \
13+
cd /tmp && \
14+
arch="$(apk --print-arch)" && \
15+
case "$arch" in \
16+
x86_64) dpkgArch='amd64' ;; \
17+
aarch64) dpkgArch='arm64' ;; \
18+
*) echo >&2 "unsupported: $arch" && exit 1 ;; \
19+
esac && \
20+
ARANGO_URL="https://download.arangodb.com/arangodb312/DEBIAN/$dpkgArch" && \
21+
ARANGO_PACKAGE="arangodb3_${ARANGO_VERSION}-1_${dpkgArch}.deb" && \
22+
ARANGO_PACKAGE_URL="${ARANGO_URL}/${ARANGO_PACKAGE}" && \
23+
ARANGO_SIGNATURE_URL="${ARANGO_PACKAGE_URL}.asc" && \
24+
wget ${ARANGO_SIGNATURE_URL} && \
25+
wget ${ARANGO_PACKAGE_URL} && \
26+
gpg --verify ${ARANGO_PACKAGE}.asc && \
27+
ar x ${ARANGO_PACKAGE} data.tar.gz && \
28+
tar -C / -x -z -f data.tar.gz && \
29+
sed -ri \
30+
-e 's!127\.0\.0\.1!0.0.0.0!g' \
31+
-e 's!^(file\s*=\s*).*!\1 -!' \
32+
-e 's!^\s*uid\s*=.*!!' \
33+
/etc/arangodb3/arangod.conf && \
34+
chgrp -R 0 /var/lib/arangodb3 /var/lib/arangodb3-apps && \
35+
chmod -R 775 /var/lib/arangodb3 /var/lib/arangodb3-apps && \
36+
rm -f ${ARANGO_PACKAGE}* data.tar.gz && \
37+
apk del gnupg
38+
# Note that Openshift runs containers by default with a random UID and GID 0.
39+
# We need that the database and apps directory are writable for this config.
40+
41+
ENV GLIBCXX_FORCE_NEW=1
42+
43+
# Adjust TZ by default since tzdata package isn't present (BTS-913)
44+
RUN echo "UTC" > /etc/timezone
45+
46+
# retain the database directory and the Foxx Application directory
47+
VOLUME ["/var/lib/arangodb3", "/var/lib/arangodb3-apps"]
48+
49+
COPY docker-entrypoint.sh /entrypoint.sh
50+
51+
ENTRYPOINT ["/entrypoint.sh"]
52+
53+
# standard port
54+
EXPOSE 8529
55+
CMD ["arangod"]

alpine/3.12.4/docker-entrypoint.sh

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ -z "$ARANGO_INIT_PORT" ] ; then
5+
ARANGO_INIT_PORT=8999
6+
fi
7+
8+
AUTHENTICATION="true"
9+
10+
# if command starts with an option, prepend arangod
11+
case "$1" in
12+
-*) set -- arangod "$@" ;;
13+
*) ;;
14+
esac
15+
16+
# check for numa
17+
NUMACTL=""
18+
19+
if [ -d /sys/devices/system/node/node1 -a -f /proc/self/numa_maps ]; then
20+
if [ "$NUMA" = "" ]; then
21+
NUMACTL="numactl --interleave=all"
22+
elif [ "$NUMA" != "disable" ]; then
23+
NUMACTL="numactl --interleave=$NUMA"
24+
fi
25+
26+
if [ "$NUMACTL" != "" ]; then
27+
if $NUMACTL echo > /dev/null 2>&1; then
28+
echo "using NUMA $NUMACTL"
29+
else
30+
echo "cannot start with NUMA $NUMACTL: please ensure that docker is running with --cap-add SYS_NICE"
31+
NUMACTL=""
32+
fi
33+
fi
34+
fi
35+
36+
if [ "$1" = 'arangod' ]; then
37+
# /var/lib/arangodb3 and /var/lib/arangodb3-apps must exist and
38+
# be writable by the user under which we run the container.
39+
40+
# Make a copy of the configuration file to patch it, note that this
41+
# must work regardless under which user we run:
42+
cp /etc/arangodb3/arangod.conf /tmp/arangod.conf
43+
44+
ARANGO_STORAGE_ENGINE=rocksdb
45+
if [ ! -z "$ARANGO_ENCRYPTION_KEYFILE" ]; then
46+
echo "Using encrypted database"
47+
sed -i /tmp/arangod.conf -e "s;^.*encryption-keyfile.*;encryption-keyfile=$ARANGO_ENCRYPTION_KEYFILE;"
48+
fi
49+
50+
if [ ! -f /var/lib/arangodb3/SERVER ] && [ "$SKIP_DATABASE_INIT" != "1" ]; then
51+
if [ ! -z "$ARANGO_ROOT_PASSWORD_FILE" ]; then
52+
if [ -f "$ARANGO_ROOT_PASSWORD_FILE" ]; then
53+
ARANGO_ROOT_PASSWORD="$(cat $ARANGO_ROOT_PASSWORD_FILE)"
54+
else
55+
echo "WARNING: password file '$ARANGO_ROOT_PASSWORD_FILE' does not exist"
56+
fi
57+
fi
58+
# Please note that the +x in the following line is for the case
59+
# that ARANGO_ROOT_PASSWORD is set but to an empty value, please
60+
# do not remove!
61+
if [ -z "${ARANGO_ROOT_PASSWORD+x}" ] && [ -z "$ARANGO_NO_AUTH" ] && [ -z "$ARANGO_RANDOM_ROOT_PASSWORD" ]; then
62+
echo >&2 'error: database is uninitialized and password option is not specified '
63+
echo >&2 " You need to specify one of ARANGO_ROOT_PASSWORD, ARANGO_ROOT_PASSWORD_FILE, ARANGO_NO_AUTH and ARANGO_RANDOM_ROOT_PASSWORD"
64+
exit 1
65+
fi
66+
67+
if [ ! -z "$ARANGO_RANDOM_ROOT_PASSWORD" ]; then
68+
ARANGO_ROOT_PASSWORD=$(pwgen -s -1 16)
69+
echo "==========================================="
70+
echo "GENERATED ROOT PASSWORD: $ARANGO_ROOT_PASSWORD"
71+
echo "==========================================="
72+
fi
73+
74+
if [ ! -z "${ARANGO_ROOT_PASSWORD+x}" ]; then
75+
echo "Initializing root user...Hang on..."
76+
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
77+
export ARANGO_ROOT_PASSWORD
78+
79+
if [ ! -z "${ARANGO_ROOT_PASSWORD}" ]; then
80+
ARANGOSH_ARGS=" --server.password ${ARANGO_ROOT_PASSWORD} "
81+
fi
82+
else
83+
ARANGOSH_ARGS=" --server.authentication false"
84+
fi
85+
86+
echo "Initializing database...Hang on..."
87+
88+
$NUMACTL arangod --config /tmp/arangod.conf \
89+
--server.endpoint tcp://127.0.0.1:$ARANGO_INIT_PORT \
90+
--server.authentication false \
91+
--log.file /tmp/init-log \
92+
--log.foreground-tty false &
93+
pid="$!"
94+
95+
counter=0
96+
ARANGO_UP=0
97+
98+
while [ "$ARANGO_UP" = "0" ]; do
99+
if [ $counter -gt 0 ]; then
100+
sleep 1
101+
fi
102+
103+
if [ "$counter" -gt 100 ]; then
104+
echo "ArangoDB didn't start correctly during init"
105+
cat /tmp/init-log
106+
exit 1
107+
fi
108+
109+
let counter=counter+1
110+
ARANGO_UP=1
111+
112+
$NUMACTL arangosh \
113+
--server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \
114+
--server.authentication false \
115+
--javascript.execute-string "db._version()" \
116+
> /dev/null 2>&1 || ARANGO_UP=0
117+
done
118+
119+
for f in /docker-entrypoint-initdb.d/*; do
120+
case "$f" in
121+
*.sh)
122+
echo "$0: running $f"
123+
. "$f"
124+
;;
125+
*.js)
126+
echo "$0: running $f"
127+
$NUMACTL arangosh ${ARANGOSH_ARGS} \
128+
--server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \
129+
--javascript.execute "$f"
130+
;;
131+
*/dumps)
132+
echo "$0: restoring databases"
133+
for d in $f/*; do
134+
DBName=$(echo ${d}|sed "s;$f/;;")
135+
echo "restoring $d into ${DBName}";
136+
$NUMACTL arangorestore \
137+
${ARANGOSH_ARGS} \
138+
--server.endpoint=tcp://127.0.0.1:$ARANGO_INIT_PORT \
139+
--create-database true \
140+
--include-system-collections true \
141+
--server.database "$DBName" \
142+
--input-directory "$d"
143+
done
144+
echo
145+
;;
146+
esac
147+
done
148+
149+
if ! kill -s TERM "$pid" || ! wait "$pid"; then
150+
echo >&2 'ArangoDB Init failed.'
151+
exit 1
152+
fi
153+
154+
echo "Database initialized...Starting System..."
155+
fi
156+
157+
# if we really want to start arangod and not bash or any other thing
158+
# prepend --authentication as the FIRST argument
159+
# (so it is overridable via command line as well)
160+
shift
161+
162+
if [ ! -z "$ARANGO_NO_AUTH" ]; then
163+
AUTHENTICATION="false"
164+
fi
165+
166+
set -- arangod "$@" --server.authentication="$AUTHENTICATION" --config /tmp/arangod.conf
167+
else
168+
NUMACTL=""
169+
fi
170+
171+
exec $NUMACTL "$@"

0 commit comments

Comments
 (0)