NixOS + home-manager configs, mirrored from GitLab SaaS. gitlab.com/andreijiroh-dev/nixops-config
nix-flake nixos home-manager nixpkgs nix-flakes
at main 51 lines 2.0 kB view raw
1#!/usr/bin/env bash 2# SPDX-License-Identifier: MPL-2.0 3# Wrapper script for managing Coolify Docker Compose setup without needing 4# to copy-paste --env-file and --file flags from the Coolify docs. 5 6COOLIFY_DIR=${COOLIFY_DIR:-"/data/coolify"} 7COOLIFY_SOURCE_DIR="${COOLIFY_DIR}/source" 8SUDO=${SUDO:-"sudo"} 9 10 11if [[ $DEBUG != "" ]]; then 12 set -x 13fi 14 15# The main entrypoint to docker-compose pointing to Coolify's compose + dotenv files, 16# after handling those compose commands. 17main() { 18 # Since the /data/coolify folder is chowned to 9999:root, we need to esclate 19 # perms via $SUDO. 20 if [[ $EUID != "0" ]]; then 21 echo "Attempting to exec as root via $(command -v ${SUDO})..." 22 exec "${SUDO}" docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \ 23 -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \ 24 -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \ 25 "$@" 26 else 27 exec docker compose --env-file "${COOLIFY_SOURCE_DIR}/.env" \ 28 -f "${COOLIFY_SOURCE_DIR}/docker-compose.yml" \ 29 -f "${COOLIFY_SOURCE_DIR}/docker-compose.prod.yml" \ 30 "$@" 31 fi 32} 33 34if [[ $1 == "up" ]]; then 35 # From the Coolify docs for manual installation steps, we always want to use these 36 # flags when bringing up. 37 # Docs: https://coolify.io/docs/get-started/installation#_7-start-coolify 38 main "$@" -d --remove-orphans --pull=always --force-recreate 39elif [[ $1 == "down" ]]; then 40 # From the Coolify docs for uninstallation steps (the Compose way of tearing down 41 # containers), we always want to use these flags when bringing down. 42 # Docs: https://coolify.io/docs/get-started/uninstallation#_1-stop-and-remove-containers 43 main "$@" --timeout=0 44elif [[ $1 == "stop" ]]; then 45 # From the Coolify docs for uninstallation steps (the `docker stop` one), we 46 # always want to use these flags when stopping 47 # Docs: https://coolify.io/docs/get-started/uninstallation#_1-stop-and-remove-containers 48 main "$@" --timeout=0 49else 50 main "$@" 51fi