1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-21 23:44:30 +00:00

Introduce the mobilizon_ctl wrapper to easily call tasks inside releases

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-10-30 15:16:33 +01:00 committed by prichier
parent 01f746a5d2
commit 005470ba5b
4 changed files with 57 additions and 7 deletions

View file

@ -36,6 +36,6 @@ USER nobody
EXPOSE 4000
COPY --from=builder --chown=nobody:nobody _build/prod/rel/mobilizon ./
COPY docker/production/docker-entrypoint.sh ./
ENTRYPOINT ["/bin/mobilizon"]
CMD ["start"]
ENTRYPOINT ["./docker-entrypoint.sh"]

View file

@ -0,0 +1,9 @@
#!/bin/sh
set -e
echo "-- Running migrations..."
/bin/mobilizon_ctl migrate
echo "-- Starting!"
exec /bin/mobilizon start

41
rel/overlays/bin/mobilizon_ctl Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh
# Portions of this file are derived from Pleroma:
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
if [ -z "$1" ] || [ "$1" = "help" ]; then
echo "Usage: $(basename "$0") COMMAND [ARGS]
The known commands are:
migrate
Execute database migrations (needs to be done after updates)
rollback [VERSION]
Rollback database migrations (needs to be done before downgrading)
and any mix tasks under Mobilizon namespace, for example \`mix mobilizon.user.show COMMAND\` is
equivalent to \`$(basename "$0") user.show COMMAND\`
By default mobilizon_ctl will try calling into a running instance to execute non migration-related commands,
if for some reason this is undesired, set MOBILIZON_CTL_RPC_DISABLED environment variable.
"
else
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
FULL_ARGS="$*"
ACTION="$1"
if [ $# -gt 0 ]; then
shift
fi
if [ "$ACTION" = "migrate" ] || [ "$ACTION" = "rollback" ] || [ "$ACTION" = "create" ] || [ "$MOBILIZON_CTL_RPC_DISABLED" = true ]; then
"$SCRIPTPATH"/mobilizon eval 'Mobilizon.CLI.run("'"$FULL_ARGS"'")'
else
"$SCRIPTPATH"/mobilizon rpc 'Mobilizon.CLI.run("'"$FULL_ARGS"'")'
fi
fi