Setup

Tab 1.

1. join org account

  1. - may be required to authorize account by signing up with credit card even when joining an already authorized main account.
  1. ( 5$ - may be refunded).

2. two ways to init

  1. command line.
  1. github connector.

3. command line tool

  1. install flyctl.
  1. https://fly.io/docs/flyctl/install.
  1. fly machine · Fly Docs.

4. login

  1. flyctl auth login (activate the correct browser window prior or copy link).

5. create app

  1. flyctl launch.
2. fly launch --org <organization-id>

3. Config file

  1. fly.toml.
  1. org cannot be specified here.
  1. 6. scale.

1. Specify number of machines (additional can be suspended - reducing billing)

  1. fly scale count 1.
  1. suspended cpu & ram is not billed.

3. RootFS is billed at (only when suspended - not while running where it is covered by normal charge)

  1. $0.15 per GB per month for used RootFS storage, prorated by time.

4. region

  1. you can have parallel servers in different regions closer to user.

7. deploy

  1. deploy.

2. redeply

2. redeply 1. fly deploy --image registry.fly.io/<prveious_image_id>

3. config only

3. config only 1. fly deploy --config fly.toml --image registry.fly.io/<app_name>:deployment-__

4. without depot

1. fly deploy --depot=false

8. Status

1. fly status

  1. shows image & machines table.

9. Image

  1. fly image show.

10. Config

1. fly config show

  1. shows detailed - including config json (NOT yaml as .toml).

2. fly config save

  1. save current config to fly.toml.

11. Custom domain

1. add dns records

  1. A record (ipv4) shared and AAAA (ipv6) record.
  1. the AAAA record is used by fly.io to connect to your app.
  1. CNAME is the alternate route.

12. SSL

12. SSL 4. fly certs add <domain>
  1. go to the certificate tab of the page.
  1. create certificate for the domain/subdomain.
  1. use wild card only when necessary.
  1. add acme_challenge dns record for certificate issuance.

13. CDN

  1. https://fly.io/docs/networking/understanding-cloudflare.
  1. disable cloudflare proxy till the issuance of the certificate.
  1. if using cloudflare proxy - delete A record as it conflicts, keep only AAAA record with strict https.

14. Scale

14. Scale 1. fly scale count <n_machines> –region <region_code>
  1. https://fly.io/docs/reference/regions.
  1. CI/CD.

# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/.

**name.** Fly Deploy.

## on

### push

### branches

- production.

## jobs

### deploy

**name.** Deploy app.

### runs-on

ubuntu-latest


### concurrency: deploy-group

# optional: ensure only one action runs at a time.

### steps

**- uses.** Actions/checkout@v4.

### - name: create .env file

### run: |

echo "NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}" > .env


**- uses.** Superfly/flyctl-actions/setup-flyctl@master.
  • run: flyctl deploy --remote-only

Env:

FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}


3. Note that the env variables required at build time for docker build has to be passed as arg to the Dockerfile.

4. get api key from app page.

ARG NEXT_PUBLIC_API_URL.

ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}


# write Vite env file so the value is inlined into the client build.

RUN printf "NEXT_PUBLIC_API_URL=%s\n" "$NEXT_PUBLIC_API_URL" > .env.production.

## 16. builder

### 1. the docker image is built of fly.io builder machines

1. this can be selected - capacity and region.

2. may have to be changed if no builder is found while deploying due to capacity exhaustion in the region.

## 17. suspend

1. suspended machines resume functioning within sub-second (to < 3-5 seconds range) range - allowing https responses to complete.

2. this can be helpful to run to seldom used apps - to run at near zero cost, and be always available.

### 3. config

## [http_service]

Auto_stop_machines = 'suspend'.

Auto_start_machines = true.

Min_machines_running = 1.

# i.e. not suspended but actually running.

Processes = ['app'].

## 18. docker stage

1. specify which stage of the docker is to be served by.

2. in fly.toml.

## [build]

build-target = "release"


## in Dockerfile

FROM base AS release.

## 19. capacity

Size = 'shared-cpu-1x'.

Memory = '512mb'.

Cpu_kind = 'shared'.

Cpus = 1.

Min memory is constrained to machine size.

And factored by no. of cpus.

## 20. monitoring

1. Manged grafana.

## 21. db

1. tunnel (for local connection - to say debug).

2. (better to keep of separate port than default).

flyctl proxy 5433 -a


## 22. pricing

1. Fly.io Resource Pricing · Fly Docs.

## 23. issues

### 1. stuck machines

1. machines getting stuck - displayed ‘red’ for no apparent reason,.

**2. could be out of memory - TODO.** Need to investigate.

3. kill fixes, ?no way to auto restart?

## 24. Terminal

1. fly ssh console.

25. sftp.

## 26. fly ssh sftp shellogs

### 1.

Fly logs.

## 27. Restart
  1. Restart 1. flyctl machine kill <machine_id> [ -a app_name ]

1. works on stuck machines.
  1. Restart 2. flyctl machine <start|stop|restart|kill> <machine_id>

### 3. policy

1. https://fly.io/docs/machines/guides-examples/machine-restart-policy.

### 2. default

### 1. on-failure

Try up to 10 times to automatically restart the Machine if it exits with a non-zero exit code, before letting it stop.

[[restart]].

policy = "<never | always | on-failure>"

Retries = 10.

Processes = ["app"].


## 28. Health Check

1. fly.io expects the web process be bound to 0.0.0.0.
Updated: 2026 Aug 19