chore: manually initialize .erlang.cookie for ct_docker

This commit is contained in:
Ivan Dyachkov 2022-11-09 10:08:59 +01:00
parent 7bbd6353aa
commit c1255188db
1 changed files with 11 additions and 5 deletions

View File

@ -89,9 +89,13 @@ for file in "${FILES[@]}"; do
F_OPTIONS="$F_OPTIONS -f $file"
done
# Passing $UID to docker-compose to be used in erlang container
# as owner of the main process to avoid git repo permissions issue.
# Permissions issue happens because we are mounting local filesystem
# where files are owned by $UID to docker container where it's using
# root (UID=0) by default, and git is not happy about it.
# shellcheck disable=2086 # no quotes for F_OPTIONS
UID_GID="$(id -u):$(id -g)"
UID_GID=$UID_GID docker-compose $F_OPTIONS up -d --build
UID_GID="$UID:$UID" docker-compose $F_OPTIONS up -d --build
# /emqx is where the source dir is mounted to the Erlang container
# in .ci/docker-compose-file/docker-compose.yaml
@ -100,8 +104,10 @@ if [[ -t 1 ]]; then
TTY='-t'
fi
docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "mkdir /.cache && chown $UID_GID /.cache"
docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "touch /.erlang.cookie && chown $UID_GID /.erlang.cookie"
# rebar and hex cache directory need to be writable by $UID
docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "mkdir /.cache && chown $UID:$UID /.cache"
# need to initialize .erlang.cookie manually here because / is not writable by $UID
docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "openssl rand -base64 16 > /.erlang.cookie && chown $UID:$UID /.erlang.cookie && chmod 0400 /.erlang.cookie"
if [ "$CONSOLE" = 'yes' ]; then
docker exec -i $TTY "$ERLANG_CONTAINER" bash -c "make run"
else
@ -109,6 +115,6 @@ else
docker exec -i $TTY "$ERLANG_CONTAINER" bash -c "make ${WHICH_APP}-ct"
RESULT=$?
# shellcheck disable=2086 # no quotes for F_OPTIONS
UID_GID=$UID_GID docker-compose $F_OPTIONS down
UID_GID="$UID:$UID" docker-compose $F_OPTIONS down
exit $RESULT
fi