Skip to content

Commit

Permalink
deploy on fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo committed Mar 28, 2024
1 parent 5a4b781 commit a336ed4
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/fly.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
47 changes: 47 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a336ed4

Please sign in to comment.