50 lines
1.6 KiB
Bash
50 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
. bin/variables.sh
|
|
. bin/functions.sh
|
|
|
|
get_ip
|
|
|
|
echo -e "${PURPLE}${BOLD}Create and push a prod branch on the repo${RESET}"
|
|
echo -e "${BLUE}git fetch . main:prod${RESET}"
|
|
echo -e "${BLUE}git push origin prod${RESET}"
|
|
echo -e "${PURPLE}${BOLD}Enter the .git url of the repo${RESET}"
|
|
read repo_url
|
|
|
|
front_repo_name=$(echo "$repo_url" | sed 's#.*/\([^/]*\)\.git#\1#')
|
|
front_directory="${REPO_DIRECTORY}/${front_repo_name}"
|
|
if [[ -z "$WEBSITE_TOKEN" ]]; then
|
|
echo -e "${PURPLE}${BOLD}Enter the Directus Website user static token${RESET}"
|
|
read -s WEBSITE_TOKEN
|
|
fi
|
|
|
|
touch /var/www/.nuxtrc
|
|
echo "telemetry.consent=0" > /var/www/.nuxtrc
|
|
echo "telemetry.enabled=false" >> /var/www/.nuxtrc
|
|
chown -R www-data:www-data /var/www/.nuxtrc
|
|
|
|
rm /var/www/html/*
|
|
chown www-data:www-data /var/www/html
|
|
|
|
su -s /bin/bash -c "cd ${REPO_DIRECTORY} &&\
|
|
git clone ${repo_url} &&\
|
|
cd ${front_directory} &&\
|
|
git checkout prod &&\
|
|
echo \"DIRECTUS_API_TOKEN=${WEBSITE_TOKEN}\" > .env &&\
|
|
echo \"URL=https://${DOMAIN_NAME}\" >> .env &&\
|
|
echo \"DIRECTUS_URL=https://cms.${DOMAIN_NAME}\" >> .env &&\
|
|
node --max-old-space-size=250 `which npm` install -y &&\
|
|
node --max-old-space-size=250 `which npm` run generate --prerender" www-data
|
|
|
|
cp -r "${front_directory}/.output/public" /var/www/html
|
|
chown -R www-data:www-data /var/www/html/public
|
|
|
|
echo "www.${DOMAIN_NAME} {" >> $CADDYFILE
|
|
echo "redir ${DOMAIN_NAME}{uri} permanent" >> $CADDYFILE
|
|
echo "}" >> $CADDYFILE
|
|
echo "${DOMAIN_NAME} {" >> $CADDYFILE
|
|
echo "root * /var/www/html/public" >> $CADDYFILE
|
|
echo "file_server" >> $CADDYFILE
|
|
echo "}" >> $CADDYFILE
|
|
caddy fmt $CADDYFILE -w
|
|
caddy reload -c $CADDYFILE |