DEV Community

Alan Schio
Alan Schio

Posted on

Deploy to Fly.io with bitbucket-pipelines

It is easy to find integrations for Github or GitLab, but i spent a couple of minutes trying to make it work, so why no sharing?

Create Fly Token

First go to your Fly.io App and create a Deploy Token (https://fly.io/apps/your-app/tokens)

Fly.io Create Deploy Token dialog

Let the Expiration if you want it to never expires

Token Generated

Add a Repository Variable

Now go to your bitbucket repository settings, under Pipeline side menu, at Repository Variables (https://bitbucket.org/YOURORG/YOURPROJECT/YOURREPO/pipelines/repository-variables).
And create a new variable with the name FLY_API_TOKEN.

Bitbucket add variable

Create the pipeline file

Now create your bitbucket-pipelines.yml file and use the golang image so you can install the flyctl and deploy your app.

image: golang:1.15
pipelines:
  default:
    - step:
        name: Deploy to Fly.io
        deployment: production
        script:
          - apt-get update -qq && apt-get install -y curl
          - curl -L https://fly.io/install.sh | sh
          - export FLYCTL_INSTALL="/root/.fly"
          - export PATH="$FLYCTL_INSTALL/bin:$PATH"
          - flyctl deploy

Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay