Skip to content

Commit

Permalink
build(fly): setup fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Callenowy committed Jan 29, 2024
1 parent 088d71a commit 7ad1f4b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for developer-app-rana on 2023-12-15T14:32:45+01:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "the-stack-app-rana"
primary_region = "waw"

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256
29 changes: 29 additions & 0 deletions scripts/fly.tmpl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# fly.toml app configuration file generated for developer-app-rana on 2023-12-15T14:32:45+01:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "the-stack-app-rana"
primary_region = "waw"

[build]

[build.args]
NEXT_PUBLIC_HOST="BUILD_NEXT_PUBLIC_HOST"
DB_PATH="BUILD_DB_PATH"
APP_PEPPER="BUILD_APP_PEPPER"
NEXTAUTH_SECRET="BUILD_NEXTAUTH_SECRET"
NEXTAUTH_URL="BUILD_NEXTAUTH_URL"

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256
20 changes: 20 additions & 0 deletions scripts/generateFly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
parent_dir="$(dirname "$script_dir")"
source_file="$script_dir/fly.tmpl.toml"
destination_file="$parent_dir/fly.toml"

export $(cat "$parent_dir/.env" | xargs)

cp $source_file $destination_file

while IFS= read -r line; do
if [[ "$line" == *"BUILD_"* ]]; then
env_var_name=$(echo "$line" | sed -n 's/.*"BUILD_\([^"]*\)".*/\1/p')
env_var_value=$(printenv "$env_var_name")
if [ ! -z "$env_var_value" ]; then
sed -i "s|BUILD_$env_var_name|$env_var_value|g" $destination_file
fi
fi
done < $destination_file

0 comments on commit 7ad1f4b

Please sign in to comment.