Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Vinícius Boscardin
Vinícius Boscardin

Posted on

     

Fly.io, alternativa ao Heroku

No dia 25/08/2022 chegou o e-mail que o heroku vai remover alguns serviços gratuitos lá em novembro. Se você assim como eu usava muito ele para hospedar alguns testes, soluções do seu github e até mesmo algumas brincadeiras. Fly.io pode ser uma solução incrível substituindo o heroku.

Como migrar seus apps

Veremos um passo a passo para realizar a migração, tanto da aplicação quanto das esteiras de deploy no github actions.

Instalação

Image description

  • Baixe e instale o SDK fornecido.

linux

curl-L https://fly.io/install.sh | sh
Enter fullscreen modeExit fullscreen mode

mac

brewinstallflyctl
Enter fullscreen modeExit fullscreen mode

windows

iwr https://fly.io/install.ps1-useb | iex
Enter fullscreen modeExit fullscreen mode
  • Faça o login com o SDK
fly auth login
Enter fullscreen modeExit fullscreen mode

Deploy

  • Na pasta raiz do seu projeto rode
fly launch# siga os passos de configuração necessários
Enter fullscreen modeExit fullscreen mode

Um arquivo chamadofly.toml será criado na raiz do projeto.

  • Altere a porta da aplicação.
[[services]]http_checks=[]internal_port=3000#porta da sua aplicação aquiprocesses=["app"]protocol="tcp"
Enter fullscreen modeExit fullscreen mode
  • Por fim rode
fly launch# orfly deploy
Enter fullscreen modeExit fullscreen mode

Acesse o link disponibilizado no fly.io e seu app estará disponível.

Image description

Github actions

Altere o arquivo de workflow do seu app. Remova tudo referente ao Heroku.

  • Adicione noarquivo_deploy.yaml.
env:FLY_API_TOKEN:${{ secrets.FLY_API_TOKEN }}
Enter fullscreen modeExit fullscreen mode
  • No seu job
-uses:superfly/flyctl-actions/setup-flyctl@master-run:flyctl deploy --remote-only --detach
Enter fullscreen modeExit fullscreen mode
  • Exemplo
name:Deploy to fly.io appon:create:tags:-v*env:FLY_API_TOKEN:${{ secrets.FLY_API_TOKEN }}jobs:build:runs-on:ubuntu-lateststeps:-uses:actions/checkout@v2-name:Config file accessrun:|rm -rf config.jsontouch config.jsonjson='{"database": {"url": "://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/"},"server": {"port": ""}}'echo "$json" > config.jsonsed -i -e 's/$DB_PORT/'${{ secrets.DB_PORT }}'/g' config.jsonsed -i -e 's/$DB_USER/'${{ secrets.DB_USER }}'/g' config.jsonsed -i -e 's/$DB_PASS/'${{ secrets.DB_PASS }}'/g' config.jsonsed -i -e 's/$DB_HOST/'${{ secrets.DB_HOST }}'/g' config.jsoncat config.json-uses:superfly/flyctl-actions/setup-flyctl@master-run:flyctl deploy --remote-only --detach
Enter fullscreen modeExit fullscreen mode

Feito, com isso seu app já está disponível gratuitamente para uso da mesma forma que fazíamos no heroku.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Challenges lover! 8 years of experience with software development.My current stack is Golang, Vue.js, Flutter, Docker, PostgreSQL, CI/CD, TDD, AWS, GCP, Digital Ocean with Clean Code/Architecture.
  • Joined

More fromVinícius Boscardin

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp