mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-12 09:39:39 -06:00
feat: prod script now supports update, delete, uninstall, stop, restart (#1691)
This commit is contained in:
committed by
GitHub
parent
4782195ca5
commit
6be825184a
@@ -29,7 +29,7 @@ Copy and paste the following command into your terminal:
|
||||
<CodeGroup title="Single Command to deploy Formbricks">
|
||||
|
||||
```bash
|
||||
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/formbricks/formbricks/main/docker/production.sh)"
|
||||
curl -fsSL https://raw.githubusercontent.com/formbricks/formbricks/main/docker/production.sh -o formbricks.sh && chmod +x formbricks.sh && ./formbricks.sh install
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
@@ -154,6 +154,69 @@ my.hosted.url.com
|
||||
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
|
||||
## Update Formbricks
|
||||
|
||||
To update Formbricks, simply run the following command:
|
||||
|
||||
<Col>
|
||||
<CodeGroup title="Update Formbricks">
|
||||
|
||||
```bash
|
||||
./formbricks.sh update
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
The script will automatically pull the latest version of Formbricks from Dockerhub and restart the containers.
|
||||
|
||||
## Stop Formbricks Instance
|
||||
|
||||
To stop Formbricks, simply run the following command:
|
||||
|
||||
<Col>
|
||||
<CodeGroup title="Stop Formbricks">
|
||||
|
||||
```bash
|
||||
./formbricks.sh stop
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
The script will automatically stop all the Formbricks related containers and brings the entire stack down.
|
||||
|
||||
## Restart Formbricks Instance
|
||||
|
||||
To restart Formbricks, simply run the following command:
|
||||
|
||||
<Col>
|
||||
<CodeGroup title="Restart Formbricks">
|
||||
|
||||
```bash
|
||||
./formbricks.sh restart
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
|
||||
The script will automatically restart all the Formbricks related containers and brings the entire stack up with the previous configuration.
|
||||
|
||||
|
||||
## Uninstall Formbricks
|
||||
|
||||
To uninstall Formbricks, simply run the following command, but keep in mind that this will delete all your data!
|
||||
|
||||
<Col>
|
||||
<CodeGroup title="Uninstall Formbricks">
|
||||
|
||||
```bash
|
||||
./formbricks.sh uninstall
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
The script will automatically stop all the Formbricks related containers, remove the Formbricks directory, and delete the Docker network.
|
||||
|
||||
## Debugging
|
||||
|
||||
If you encounter any issues, you can check the logs of the container with:
|
||||
@@ -168,6 +231,7 @@ cd formbricks && docker compose logs -f
|
||||
</Col>
|
||||
You can close the logs again with `CTRL + C`.
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter any issues, consider the following steps:
|
||||
|
||||
268
docker/production.sh
Normal file → Executable file
268
docker/production.sh
Normal file → Executable file
@@ -3,70 +3,71 @@
|
||||
set -e
|
||||
ubuntu_version=$(lsb_release -a 2>/dev/null | grep -v "No LSB modules are available." | grep "Description:" | awk -F "Description:\t" '{print $2}')
|
||||
|
||||
# Friendly welcome
|
||||
echo "🧱 Welcome to the Formbricks single instance installer"
|
||||
echo ""
|
||||
echo "🛸 Fasten your seatbelts! We're setting up your Formbricks environment on your $ubuntu_version server."
|
||||
echo ""
|
||||
install_formbricks() {
|
||||
# Friendly welcome
|
||||
echo "🧱 Welcome to the Formbricks Setup Script"
|
||||
echo ""
|
||||
echo "🛸 Fasten your seatbelts! We're setting up your Formbricks environment on your $ubuntu_version server."
|
||||
echo ""
|
||||
|
||||
# Remove any old Docker installations, without stopping the script if they're not found
|
||||
echo "🧹 Time to sweep away any old Docker installations."
|
||||
sudo apt-get remove docker docker-engine docker.io containerd runc >/dev/null 2>&1 || true
|
||||
# Remove any old Docker installations, without stopping the script if they're not found
|
||||
echo "🧹 Time to sweep away any old Docker installations."
|
||||
sudo apt-get remove docker docker-engine docker.io containerd runc >/dev/null 2>&1 || true
|
||||
|
||||
# Update package list
|
||||
echo "🔄 Updating your package list."
|
||||
sudo apt-get update >/dev/null 2>&1
|
||||
# Update package list
|
||||
echo "🔄 Updating your package list."
|
||||
sudo apt-get update >/dev/null 2>&1
|
||||
|
||||
# Install dependencies
|
||||
echo "📦 Installing the necessary dependencies."
|
||||
sudo apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release >/dev/null 2>&1
|
||||
# Install dependencies
|
||||
echo "📦 Installing the necessary dependencies."
|
||||
sudo apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release >/dev/null 2>&1
|
||||
|
||||
# Set up Docker's official GPG key & stable repository
|
||||
echo "🔑 Adding Docker's official GPG key and setting up the stable repository."
|
||||
sudo mkdir -m 0755 -p /etc/apt/keyrings >/dev/null 2>&1
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg >/dev/null 2>&1
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
# Set up Docker's official GPG key & stable repository
|
||||
echo "🔑 Adding Docker's official GPG key and setting up the stable repository."
|
||||
sudo mkdir -m 0755 -p /etc/apt/keyrings >/dev/null 2>&1
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg >/dev/null 2>&1
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null 2>&1
|
||||
|
||||
# Update package list again
|
||||
echo "🔄 Updating your package list again."
|
||||
sudo apt-get update >/dev/null 2>&1
|
||||
# Update package list again
|
||||
echo "🔄 Updating your package list again."
|
||||
sudo apt-get update >/dev/null 2>&1
|
||||
|
||||
# Install Docker
|
||||
echo "🐳 Installing Docker."
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin >/dev/null 2>&1
|
||||
# Install Docker
|
||||
echo "🐳 Installing Docker."
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin >/dev/null 2>&1
|
||||
|
||||
# Test Docker installation
|
||||
echo "🚀 Testing your Docker installation."
|
||||
if docker --version >/dev/null 2>&1; then
|
||||
echo "🎉 Docker is installed!"
|
||||
else
|
||||
echo "❌ Docker is not installed. Please install Docker before proceeding."
|
||||
exit 1
|
||||
fi
|
||||
# Test Docker installation
|
||||
echo "🚀 Testing your Docker installation."
|
||||
if docker --version >/dev/null 2>&1; then
|
||||
echo "🎉 Docker is installed!"
|
||||
else
|
||||
echo "❌ Docker is not installed. Please install Docker before proceeding."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Adding your user to the Docker group
|
||||
echo "🐳 Adding your user to the Docker group to avoid using sudo with docker commands."
|
||||
sudo groupadd docker >/dev/null 2>&1 || true
|
||||
sudo usermod -aG docker $USER >/dev/null 2>&1
|
||||
# Adding your user to the Docker group
|
||||
echo "🐳 Adding your user to the Docker group to avoid using sudo with docker commands."
|
||||
sudo groupadd docker >/dev/null 2>&1 || true
|
||||
sudo usermod -aG docker $USER >/dev/null 2>&1
|
||||
|
||||
echo "🎉 Hooray! Docker is all set and ready to go. You're now ready to run your Formbricks instance!"
|
||||
echo "🎉 Hooray! Docker is all set and ready to go. You're now ready to run your Formbricks instance!"
|
||||
|
||||
# Installing Traefik
|
||||
echo "🚗 Installing Traefik..."
|
||||
mkdir -p formbricks && cd formbricks
|
||||
echo "📁 Created Formbricks Quickstart directory at ./formbricks."
|
||||
# Installing Traefik
|
||||
echo "🚗 Installing Traefik..."
|
||||
mkdir -p formbricks && cd formbricks
|
||||
echo "📁 Created Formbricks Quickstart directory at ./formbricks."
|
||||
|
||||
# Ask the user for their email address
|
||||
echo "💡 Please enter your email address for the SSL certificate:"
|
||||
read email_address
|
||||
# Ask the user for their email address
|
||||
echo "💡 Please enter your email address for the SSL certificate:"
|
||||
read email_address
|
||||
|
||||
cat <<EOT >traefik.yaml
|
||||
cat <<EOT >traefik.yaml
|
||||
entryPoints:
|
||||
web:
|
||||
address: ":80"
|
||||
@@ -94,72 +95,71 @@ certificatesResolvers:
|
||||
tlsChallenge: {}
|
||||
EOT
|
||||
|
||||
echo "💡 Created traefik.yaml file with your provided email address."
|
||||
echo "💡 Created traefik.yaml file with your provided email address."
|
||||
|
||||
touch acme.json
|
||||
chmod 600 acme.json
|
||||
echo "💡 Created acme.json file with correct permissions."
|
||||
touch acme.json
|
||||
chmod 600 acme.json
|
||||
echo "💡 Created acme.json file with correct permissions."
|
||||
|
||||
# Ask the user for their domain name
|
||||
echo "🔗 Please enter your domain name for the SSL certificate (🚨 do NOT enter the protocol (http/https/etc)):"
|
||||
read domain_name
|
||||
# Ask the user for their domain name
|
||||
echo "🔗 Please enter your domain name for the SSL certificate (🚨 do NOT enter the protocol (http/https/etc)):"
|
||||
read domain_name
|
||||
|
||||
# Prompt for email service setup
|
||||
read -p "Do you want to set up the email service? (yes/no) You will need SMTP credentials for the same! " email_service
|
||||
if [[ $email_service == "yes" ]]; then
|
||||
echo "Please provide the following email service details: "
|
||||
# Prompt for email service setup
|
||||
read -p "Do you want to set up the email service? (yes/no) You will need SMTP credentials for the same! " email_service
|
||||
if [[ $email_service == "yes" ]]; then
|
||||
echo "Please provide the following email service details: "
|
||||
|
||||
echo -n "Enter your SMTP configured Email ID: "
|
||||
read mail_from
|
||||
echo -n "Enter your SMTP configured Email ID: "
|
||||
read mail_from
|
||||
|
||||
echo -n "Enter your SMTP Host URL: "
|
||||
read smtp_host
|
||||
echo -n "Enter your SMTP Host URL: "
|
||||
read smtp_host
|
||||
|
||||
echo -n "Enter your SMTP Host Port: "
|
||||
read smtp_port
|
||||
echo -n "Enter your SMTP Host Port: "
|
||||
read smtp_port
|
||||
|
||||
echo -n "Enter your SMTP username: "
|
||||
read smtp_user
|
||||
echo -n "Enter your SMTP username: "
|
||||
read smtp_user
|
||||
|
||||
echo -n "Enter your SMTP password: "
|
||||
read smtp_password
|
||||
echo -n "Enter your SMTP password: "
|
||||
read smtp_password
|
||||
|
||||
echo -n "Enable Secure SMTP (use SSL)? Enter 1 for yes and 0 for no: "
|
||||
read smtp_secure_enabled
|
||||
echo -n "Enable Secure SMTP (use SSL)? Enter 1 for yes and 0 for no: "
|
||||
read smtp_secure_enabled
|
||||
|
||||
else
|
||||
mail_from=""
|
||||
smtp_host=""
|
||||
smtp_port=""
|
||||
smtp_user=""
|
||||
smtp_password=""
|
||||
smtp_secure_enabled=0
|
||||
fi
|
||||
else
|
||||
mail_from=""
|
||||
smtp_host=""
|
||||
smtp_port=""
|
||||
smtp_user=""
|
||||
smtp_password=""
|
||||
smtp_secure_enabled=0
|
||||
fi
|
||||
|
||||
echo "📥 Downloading docker-compose.yml from Formbricks GitHub repository..."
|
||||
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
|
||||
echo "📥 Downloading docker-compose.yml from Formbricks GitHub repository..."
|
||||
curl -o docker-compose.yml https://raw.githubusercontent.com/formbricks/formbricks/main/docker/docker-compose.yml
|
||||
|
||||
echo "🚙 Updating docker-compose.yml with your custom inputs..."
|
||||
sed -i "/WEBAPP_URL:/s|WEBAPP_URL:.*|WEBAPP_URL: \"https://$domain_name\"|" docker-compose.yml
|
||||
sed -i "/NEXTAUTH_URL:/s|NEXTAUTH_URL:.*|NEXTAUTH_URL: \"https://$domain_name\"|" docker-compose.yml
|
||||
echo "🚙 Updating docker-compose.yml with your custom inputs..."
|
||||
sed -i "/WEBAPP_URL:/s|WEBAPP_URL:.*|WEBAPP_URL: \"https://$domain_name\"|" docker-compose.yml
|
||||
sed -i "/NEXTAUTH_URL:/s|NEXTAUTH_URL:.*|NEXTAUTH_URL: \"https://$domain_name\"|" docker-compose.yml
|
||||
|
||||
nextauth_secret=$(openssl rand -hex 32) && sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $nextauth_secret/" docker-compose.yml
|
||||
echo "🚗 NEXTAUTH_SECRET updated successfully!"
|
||||
nextauth_secret=$(openssl rand -hex 32) && sed -i "/NEXTAUTH_SECRET:$/s/NEXTAUTH_SECRET:.*/NEXTAUTH_SECRET: $nextauth_secret/" docker-compose.yml
|
||||
echo "🚗 NEXTAUTH_SECRET updated successfully!"
|
||||
|
||||
encryption_key=$(openssl rand -hex 32) && sed -i "/ENCRYPTION_KEY:$/s/ENCRYPTION_KEY:.*/ENCRYPTION_KEY: $encryption_key/" docker-compose.yml
|
||||
echo "🚗 ENCRYPTION_KEY updated successfully!"
|
||||
encryption_key=$(openssl rand -hex 32) && sed -i "/ENCRYPTION_KEY:$/s/ENCRYPTION_KEY:.*/ENCRYPTION_KEY: $encryption_key/" docker-compose.yml
|
||||
echo "🚗 ENCRYPTION_KEY updated successfully!"
|
||||
|
||||
if [[ -n $mail_from ]]; then
|
||||
sed -i "s|# MAIL_FROM:|MAIL_FROM: \"$mail_from\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_HOST:|SMTP_HOST: \"$smtp_host\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_PORT:|SMTP_PORT: \"$smtp_port\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_SECURE_ENABLED:|SMTP_SECURE_ENABLED: $smtp_secure_enabled|" docker-compose.yml
|
||||
sed -i "s|# SMTP_USER:|SMTP_USER: \"$smtp_user\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_PASSWORD:|SMTP_PASSWORD: \"$smtp_password\"|" docker-compose.yml
|
||||
fi
|
||||
|
||||
if [[ -n $mail_from ]]; then
|
||||
sed -i "s|# MAIL_FROM:|MAIL_FROM: \"$mail_from\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_HOST:|SMTP_HOST: \"$smtp_host\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_PORT:|SMTP_PORT: \"$smtp_port\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_SECURE_ENABLED:|SMTP_SECURE_ENABLED: $smtp_secure_enabled|" docker-compose.yml
|
||||
sed -i "s|# SMTP_USER:|SMTP_USER: \"$smtp_user\"|" docker-compose.yml
|
||||
sed -i "s|# SMTP_PASSWORD:|SMTP_PASSWORD: \"$smtp_password\"|" docker-compose.yml
|
||||
fi
|
||||
|
||||
awk -v domain_name="$domain_name" '
|
||||
awk -v domain_name="$domain_name" '
|
||||
/formbricks:/,/^ *$/ {
|
||||
if ($0 ~ /depends_on:/) {
|
||||
inserting_labels=1
|
||||
@@ -195,9 +195,9 @@ awk -v domain_name="$domain_name" '
|
||||
1
|
||||
' docker-compose.yml >tmp.yml && mv tmp.yml docker-compose.yml
|
||||
|
||||
newgrp docker <<END
|
||||
newgrp docker <<END
|
||||
|
||||
docker compose up
|
||||
docker compose up -d
|
||||
|
||||
echo "🔗 To edit more variables and deeper config, go to the formbricks/docker-compose.yml, edit the file, and restart the container!"
|
||||
|
||||
@@ -206,3 +206,65 @@ echo ""
|
||||
echo "🎉 All done! Check the status of Formbricks & Traefik with 'cd formbricks && sudo docker compose ps.'"
|
||||
|
||||
END
|
||||
|
||||
}
|
||||
|
||||
uninstall_formbricks() {
|
||||
echo "🗑️ Preparing to Uninstalling Formbricks..."
|
||||
read -p "Are you sure you want to uninstall Formbricks? This will delete all the data associated with it! (yes/no): " uninstall_confirmation
|
||||
if [[ $uninstall_confirmation == "yes" ]]; then
|
||||
cd formbricks
|
||||
sudo docker compose down
|
||||
cd ..
|
||||
sudo rm -rf formbricks
|
||||
echo "🛑 Formbricks uninstalled successfully!"
|
||||
else
|
||||
echo "❌ Uninstalling Formbricks has been cancelled."
|
||||
fi
|
||||
}
|
||||
|
||||
stop_formbricks() {
|
||||
echo "🛑 Stopping Formbricks..."
|
||||
cd formbricks
|
||||
sudo docker compose down
|
||||
echo "🎉 Formbricks instance stopped successfully!"
|
||||
}
|
||||
|
||||
update_formbricks() {
|
||||
echo "🔄 Updating Formbricks..."
|
||||
cd formbricks
|
||||
sudo docker compose pull
|
||||
sudo docker compose down
|
||||
sudo docker compose up -d
|
||||
echo "🎉 Formbricks updated successfully!"
|
||||
echo "🎉 Check the status of Formbricks & Traefik with 'cd formbricks && sudo docker compose logs.'"
|
||||
}
|
||||
|
||||
restart_formbricks() {
|
||||
echo "🔄 Restarting Formbricks..."
|
||||
cd formbricks
|
||||
sudo docker compose restart
|
||||
echo "🎉 Formbricks restarted successfully!"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
install_formbricks
|
||||
;;
|
||||
update)
|
||||
update_formbricks
|
||||
;;
|
||||
stop)
|
||||
stop_formbricks
|
||||
;;
|
||||
restart)
|
||||
restart_formbricks
|
||||
;;
|
||||
uninstall)
|
||||
uninstall_formbricks
|
||||
;;
|
||||
*)
|
||||
echo "🚀 Executing default step of installing Formbricks"
|
||||
install_formbricks
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user