diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 0000000..c539b7c --- /dev/null +++ b/.github/workflows/fly.yml @@ -0,0 +1,20 @@ +name: Fly Deploy +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy: + name: Deploy core app + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --config ./fly.toml --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/README.md b/README.md index 2726f6d..3cce532 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,23 @@ Then run the app in production mode: ```sh yarn start ``` + +### Fly.io Setup + +1. Create an account on [Fly.io](https://fly.io) +1. Install the [Fly CLI](https://fly.io/docs/getting-started/installing-flyctl/) +1. Run `flyctl login` and follow the prompts +1. Run `flyctl launch` in the project root +1. Enter `y` to `copy its configuration to the new app` +1. Enter `N` to `tweak these settings` +1. The app should deploy now +1. Now you can set up the Github Action + +### Github Action + +1. Create a deploy token by running `flyctl tokens create deploy` +1. Create a new secret on your repository called `FLY_API_TOKEN` with your deploy token at `Settings > Secrets and Variables > Actions` + +## Media Files + +Media files should be stored in a S3 bucket. Create a bucket at Cloudflare, AWS, or any other provider and fill the required environment variables in the .env file. When using Cloudflare R2, specify `S3_REGION=auto` diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..4731e92 --- /dev/null +++ b/fly.toml @@ -0,0 +1,47 @@ +# fly.toml app configuration file generated for walls-and-birds on 2024-03-28T17:53:49+01:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'walls-and-birds' +primary_region = 'ams' +kill_signal = 'SIGINT' +kill_timeout = '5s' + +[build] + dockerfile = 'Dockerfile' + +[env] + PORT = '8080' + +[http_service] + internal_port = 8080 + force_https = true + processes = ['app'] + +[[services]] + protocol = 'tcp' + internal_port = 8080 + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 1 + processes = ['app'] + +[[services.ports]] + port = 80 + handlers = ['http'] + force_https = true + +[[services.ports]] + port = 443 + handlers = ['tls', 'http'] + + [services.concurrency] + type = 'requests' + hard_limit = 250 + soft_limit = 200 + +[[vm]] + cpu_kind = 'shared' + cpus = 1 + memory_mb = 512