59 lines
1.5 KiB
Plaintext
59 lines
1.5 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# -e Exit immediately if a command exits with a non-zero status.
|
||
|
# -u Treat unset variables as an error when substituting.
|
||
|
set -eu
|
||
|
|
||
|
START=`date +%s`
|
||
|
PROJECT=slides
|
||
|
|
||
|
build_production() {
|
||
|
echo "👷 Construction du site en mode production"
|
||
|
rm -rf public
|
||
|
hugo --environment production --minify
|
||
|
}
|
||
|
|
||
|
help() {
|
||
|
echo "💡 Aide"
|
||
|
echo "-------"
|
||
|
echo
|
||
|
echo "Commandes :"
|
||
|
echo "- ./run install 📦 Installation des dépendances"
|
||
|
echo "- ./run dev 🚧 Lancement du serveur pour le développement"
|
||
|
echo "- ./run build 👷 Construction du site en mode production"
|
||
|
echo "- ./run docker 🐳 Création de l'image Docker"
|
||
|
echo "- ./run deploy 🚀 Déploiement avec docker-compose"
|
||
|
echo
|
||
|
}
|
||
|
|
||
|
install() {
|
||
|
echo "📦 Installation des dépendances"
|
||
|
git submodule update --init
|
||
|
}
|
||
|
|
||
|
if [ $# -ge 1 ]; then
|
||
|
if [ $1 == "dev" ]; then
|
||
|
echo "🚧 Lancement du serveur pour le développement"
|
||
|
hugo server -D
|
||
|
elif [ $1 == "build" ]; then
|
||
|
build_production
|
||
|
elif [ $1 == "docker" ]; then
|
||
|
echo "🐳 Création de l'image Docker"
|
||
|
echo
|
||
|
docker build . -t kosssi/$PROJECT
|
||
|
docker tag kosssi/$PROJECT registry.lamelio.fr/$PROJECT
|
||
|
docker push registry.lamelio.fr/$PROJECT
|
||
|
elif [ $1 == "deploy" ]; then
|
||
|
echo "🚀 Déploiement avec docker-compose"
|
||
|
echo
|
||
|
docker-compose up -d
|
||
|
elif [ $1 == "install" ]; then
|
||
|
install
|
||
|
fi
|
||
|
else
|
||
|
help
|
||
|
fi
|
||
|
|
||
|
END=`date +%s`
|
||
|
echo "✨ Done in $((END-START))s"
|