deploy nuxt

This commit is contained in:
Valentin 2024-02-25 17:14:22 +01:00
parent c5a18dd39b
commit cce95dc9e4
1 changed files with 58 additions and 20 deletions

View File

@ -90,12 +90,6 @@ if [[ "$answer" == "y" ]]; then
ufw allow https
fi
#
# TODO : ZABBIX AND URBACKUP
#
echo -e "${PURPLE}${BOLD}TODO : Zabbix and Urbackup${RESET}"
#
# CADDY
#
@ -266,9 +260,8 @@ if [[ "$answer" == "y" ]]; then
npm init -y &&\
npx directus bootstrap --skipAdminInit" $username
session="directus"
su -c "tmux new-session -d -s ${session} &&\
tmux send-keys -t ${session} \"cd /home/${username}/${cms_folder} && npx directus start\" C-m" $username
su -c "tmux new-session -d -s directus &&\
tmux send-keys -t directus \"cd /home/${username}/${cms_folder} && npx directus start\" C-m" $username
su -c "cd /home/${username}/${cms_folder} &&\
npx directus roles create --role Administrator --admin true &&\
@ -299,28 +292,73 @@ if [[ "$answer" == "y" ]]; then
echo "}" >> $caddyfile
caddy fmt $caddyfile -w
caddy reload -c $caddyfile
fi
#
# DIRECTUS IMPORTS
#
echo -e "${PURPLE}${BOLD}Import Directus data model and content ? (y/N) ${RESET}"
echo -e "${PURPLE}${BOLD}Import Directus data model ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
get_username
get_ip
echo -e "${PURPLE}${BOLD}Import local Directus data model${RESET}"
echo -e "${PURPLE}npx directus schema snapshot ./snapshot.yaml${RESET}"
echo -e "${PURPLE}scp ${username}@${ip}:/home/${username}/snapshot.yaml /path/to/snapshot.yaml${RESET}"
echo -e "${PURPLE}scp /local/path/to/snapshot.yaml ${username}@${ip}:/home/${username}/snapshot.yaml${RESET}"
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
read
su -c "cd /home/${username}/${cms_folder} &&\
npx directus schema apply --dry-run --yes ../snapshot.yaml" $username
npx directus schema apply --yes ../snapshot.yaml" $username
echo -e "${PURPLE}${BOLD}You can now add some content${RESET}"
echo -e "${ORANGE}${BOLD}Do not forget to set the permissions${RESET}"
echo -e "${ORANGE}${BOLD}Website role ${RESET}${ORANGE}Read content collections and directus_files${RESET}"
echo -e "${ORANGE}${BOLD}User role ${RESET}${ORANGE}All permissions on content collections and directus_files${RESET}"
fi
echo -e "${PURPLE}${BOLD}Access Directus ${RESET}${PURPLE}https://cms.${domain_name}${RESET}"
fi
#
# NUXT
#
echo -e "${PURPLE}${BOLD}Install the front-end ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
get_username
echo -e "${PURPLE}${BOLD}Create and push a prod branch on the repo${RESET}"
echo -e "${PURPLE}git checkout -b prod${RESET}"
echo -e "${PURPLE}git add . && git commit -m "first commit to prod"${RESET}"
echo -e "${PURPLE}git push origin prod${RESET}"
echo -e "${PURPLE}${BOLD}What is the .git url of the repo${RESET}"
read repo_url
front_folder=$(echo "$repo_url" | sed 's#.*/\([^/]*\)\.git#\1#')
if [[ -z "$website_token" ]]; then
echo -e "${PURPLE}${BOLD}Enter the Directus Website user static token${RESET}"
read website_token
fi
su -c "cd /home/${username} &&\
git clone ${repo_url} &&\
cd ${front_folder} &&\
git checkout prod &&\
echo \"DIRECTUS_API_TOKEN=${website_token}\" > .env &&\
echo \"URL=https://${domain_name}\" >> .env &&\
echo \"DIRECTUS_URL=https://cms.${domain_name}\" >> .env &&\
npm install &&\
tmux send-keys -t directus C-c &&\
npm run build &&\
tmux new-session -d -s front &&\
tmux send-keys -t front \"cd /home/${username}/${front_folder} && node .output/server/index.mjs\" C-m &&\
tmux send-keys -t directus "npx directus start" C-m" $username
echo -e "${PURPLE}${BOLD}Setup a webhook ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
fi
fi
# TODO
# REMOVE EXPECT AT THE END IF IT IS INSTALLED
# CREATE AN ASSETS FOLDER WITH THE DIRECTUS ENV