Last active
October 7, 2024 05:41
-
-
Save smartium/cf5f678bc852058fb65fd421c6b06497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ./deploy.sh create --> create fly.io project | |
| # ./deploy.sh --> only update project | |
| if ! command -v flyctl &>/dev/null; then | |
| echo "flyctl isn't installed! Opening fly.io installation instructions..." | |
| sleep 3 | |
| open https://fly.io/docs/getting-started/installing-flyctl/ | |
| exit | |
| else | |
| if [ "$#" -eq "1" ]; then | |
| if [ "$1" = "create" ]; then | |
| # CREATE NPM PACKAGE AND LOGIN INTO FLY.IO: | |
| flyctl auth login | |
| npm init -y # new npm package | |
| npm install --save serve # install server package. Run on port 3000 | |
| sed -i '' 's/"test"/"start"/' package.json | |
| sed -i '' 's/echo \\"Error: no test specified\\" && exit 1/serve .\//g' package.json | |
| export THORIUM_PROJECT_NAME="$(grep -o '"name": "[^"]*' package.json | grep -o '[^"]*$')" # get project name from packages.json | |
| export PROJECT="${THORIUM_PROJECT_NAME//[_]/-}" # fly.io only accepts dashes | |
| cat <<EOT >>fly.toml | |
| app = "$PROJECT" | |
| kill_signal = "SIGINT" | |
| kill_timeout = 5 | |
| processes = [] | |
| [build] | |
| builder = "heroku/buildpacks:20" | |
| [env] | |
| PORT = "8080" | |
| [experimental] | |
| allowed_public_ports = [] | |
| auto_rollback = true | |
| [[services]] | |
| http_checks = [] | |
| internal_port = 8080 | |
| processes = ["app"] | |
| protocol = "tcp" | |
| script_checks = [] | |
| [services.concurrency] | |
| hard_limit = 25 | |
| soft_limit = 20 | |
| type = "connections" | |
| [[services.ports]] | |
| force_https = true | |
| handlers = ["http"] | |
| port = 80 | |
| [[services.ports]] | |
| handlers = ["tls", "http"] | |
| port = 443 | |
| [[services.tcp_checks]] | |
| grace_period = "1s" | |
| interval = "15s" | |
| restart_limit = 0 | |
| timeout = "2s" | |
| EOT | |
| # fly.io will automatically identify that it is a Node.js application | |
| echo "GENERATING APP..." | |
| flyctl launch --copy-config --name $PROJECT --no-deploy | |
| fi | |
| fi | |
| echo "DEPLOYING APP..." | |
| flyctl deploy --now | |
| echo "OPENING APP ON BROWSER" | |
| sleep 3 | |
| open "https://$PROJECT.fly.dev" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, can I ask you to add a new provider for thorium deployment?