···77COOLIFY_SOURCE_DIR="${COOLIFY_DIR}/source"
88SUDO=${SUDO:-"sudo"}
991010-# Since the /data/coolify folder is chowned to 9999:root, we need to esclate
1111-# perms via $SUDO.
1212-if [[ $EUID != "0" ]]; then
1313- echo "Attempting to exec as root via $(command -v ${SUDO})..."
1414- exec "${SUDO}" docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \
1515- -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \
1616- -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \
1717- "$@"
1010+# The main entrypoint to docker-compose pointing to Coolify's compose + dotenv files,
1111+# after handling those compose commands.
1212+main() {
1313+ # Since the /data/coolify folder is chowned to 9999:root, we need to esclate
1414+ # perms via $SUDO.
1515+ if [[ $EUID != "0" ]]; then
1616+ echo "Attempting to exec as root via $(command -v ${SUDO})..."
1717+ exec "${SUDO}" docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \
1818+ -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \
1919+ -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \
2020+ "$@"
2121+ else
2222+ exec docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \
2323+ -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \
2424+ -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \
2525+ "$@"
2626+ fi
2727+}
2828+2929+if [[ $1 == "up" ]]; then
3030+ # From the Coolify docs for manual installation steps, we always want to use these
3131+ # flags when bringing up.
3232+ # Docs: https://coolify.io/docs/get-started/installation#_7-start-coolify
3333+ main up -d --remove-orphans --pull=always --force-recreate "$@"
3434+elif [[ $1 == "down" ]]; then
3535+ # From the Coolify docs for uninstallation steps (the Compose way of tearing down
3636+ # containers), we always want to use these flags when bringing down.
3737+ # Docs: https://coolify.io/docs/get-started/uninstallation#_1-stop-and-remove-containers
3838+ main down --timeout=0 "$@"
3939+elif [[ $1 == "stop" ]]; then
4040+ # From the Coolify docs for uninstallation steps (the `docker stop` one), we
4141+ # always want to use these flags when stopping
4242+ # Docs: https://coolify.io/docs/get-started/uninstallation#_1-stop-and-remove-containers
4343+ main stop --timeout=0 "$@"
1844else
1919- exec docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \
2020- -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \
2121- -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \
2222- "$@"
4545+ main "$@"
2346fi