Skip to content

Commit 6a29be1

Browse files
committed
Several fixes for ArangoDB official docker
1 parent 26a907a commit 6a29be1

File tree

7 files changed

+253
-11
lines changed

7 files changed

+253
-11
lines changed

alpine/3.5.5.1/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.10
1+
FROM alpine:3.11
22
MAINTAINER Frank Celler <info@arangodb.com>
33

44
ENV ARANGO_VERSION 3.5.5.1
@@ -11,9 +11,9 @@ ENV ARANGO_SIGNATURE_URL ${ARANGO_PACKAGE_URL}.asc
1111
# https://www.arangodb.com/docs/3.5/programs-arangod-server.html#managing-endpoints
1212
# https://www.arangodb.com/docs/3.5/programs-arangod-log.html
1313

14-
RUN apk add --no-cache gnupg pwgen nodejs npm binutils numactl numactl-tools && \
15-
npm install -g foxx-cli@1.3.0 && \
16-
rm -rf /root/.npm && \
14+
RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools nodejs yarn && \
15+
yarn global add foxx-cli && \
16+
apk del yarn && \
1717
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B && \
1818
mkdir /docker-entrypoint-initdb.d && \
1919
cd /tmp && \

alpine/3.5.5.1/docker-foxx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
test -d /tmp/foxx || mkdir -m 700 /tmp/foxx
33
export HOME=/tmp/foxx
4-
exec /usr/lib/node_modules/foxx-cli/bin/foxx "$@"
4+
exec /usr/local/share/.config/yarn/global/node_modules/.bin/foxx "$@"

alpine/3.6.5/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.10
1+
FROM alpine:3.11
22
MAINTAINER Frank Celler <info@arangodb.com>
33

44
ENV ARANGO_VERSION 3.6.5
@@ -11,10 +11,9 @@ ENV ARANGO_SIGNATURE_URL ${ARANGO_PACKAGE_URL}.asc
1111
# https://www.arangodb.com/docs/3.6/programs-arangod-server.html#managing-endpoints
1212
# https://www.arangodb.com/docs/3.6/programs-arangod-log.html
1313

14-
RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools && \
15-
apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main/ nodejs npm && \
16-
npm install -g foxx-cli && \
17-
rm -rf /root/.npm && apk del npm && \
14+
RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools nodejs yarn && \
15+
yarn global add foxx-cli && \
16+
apk del yarn && \
1817
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B && \
1918
mkdir /docker-entrypoint-initdb.d && \
2019
cd /tmp && \

alpine/3.6.5/docker-foxx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
test -d /tmp/foxx || mkdir -m 700 /tmp/foxx
33
export HOME=/tmp/foxx
4-
exec /usr/lib/node_modules/foxx-cli/bin/foxx "$@"
4+
exec /usr/local/share/.config/yarn/global/node_modules/.bin/foxx "$@"

alpine/3.7.1/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM alpine:3.11
2+
MAINTAINER Frank Celler <info@arangodb.com>
3+
4+
ENV ARANGO_VERSION 3.7.1
5+
ENV ARANGO_URL https://download.arangodb.com/arangodb37/DEBIAN/amd64
6+
ENV ARANGO_PACKAGE arangodb3_${ARANGO_VERSION}-1_amd64.deb
7+
ENV ARANGO_PACKAGE_URL ${ARANGO_URL}/${ARANGO_PACKAGE}
8+
ENV ARANGO_SIGNATURE_URL ${ARANGO_PACKAGE_URL}.asc
9+
10+
# see
11+
# https://www.arangodb.com/docs/3.7/programs-arangod-server.html#managing-endpoints
12+
# https://www.arangodb.com/docs/3.7/programs-arangod-log.html
13+
14+
RUN apk add --no-cache gnupg pwgen binutils numactl numactl-tools nodejs yarn && \
15+
yarn global add foxx-cli && \
16+
apk del yarn && \
17+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys CD8CB0F1E0AD5B52E93F41E7EA93F5E56E751E9B && \
18+
mkdir /docker-entrypoint-initdb.d && \
19+
cd /tmp && \
20+
wget ${ARANGO_SIGNATURE_URL} && \
21+
wget ${ARANGO_PACKAGE_URL} && \
22+
gpg --verify ${ARANGO_PACKAGE}.asc && \
23+
ar x ${ARANGO_PACKAGE} data.tar.gz && \
24+
tar -C / -x -z -f data.tar.gz && \
25+
sed -ri \
26+
-e 's!127\.0\.0\.1!0.0.0.0!g' \
27+
-e 's!^(file\s*=\s*).*!\1 -!' \
28+
-e 's!^\s*uid\s*=.*!!' \
29+
/etc/arangodb3/arangod.conf && \
30+
echo chgrp -R 0 /var/lib/arangodb3 /var/lib/arangodb3-apps && \
31+
echo chmod -R 775 /var/lib/arangodb3 /var/lib/arangodb3-apps && \
32+
rm -f /usr/bin/foxx && \
33+
rm -f ${ARANGO_PACKAGE}* data.tar.gz && \
34+
apk del gnupg
35+
# Note that Openshift runs containers by default with a random UID and GID 0.
36+
# We need that the database and apps directory are writable for this config.
37+
38+
# retain the database directory and the Foxx Application directory
39+
VOLUME ["/var/lib/arangodb3", "/var/lib/arangodb3-apps"]
40+
41+
COPY docker-entrypoint.sh /entrypoint.sh
42+
COPY docker-foxx.sh /usr/bin/foxx
43+
44+
ENTRYPOINT ["/entrypoint.sh"]
45+
46+
# standard port
47+
EXPOSE 8529
48+
CMD ["arangod"]

alpine/3.7.1/docker-entrypoint.sh

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

alpine/3.7.1/docker-foxx.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
test -d /tmp/foxx || mkdir -m 700 /tmp/foxx
3+
export HOME=/tmp/foxx
4+
exec /usr/local/share/.config/yarn/global/node_modules/.bin/foxx "$@"

0 commit comments

Comments
 (0)