{"id":16179298,"url":"https://github.com/jonashackt/flyio-buildpacks-devfriday","last_synced_at":"2026-02-22T16:03:56.610Z","repository":{"id":147269691,"uuid":"531841574","full_name":"jonashackt/flyio-buildpacks-devfriday","owner":"jonashackt","description":"Having a look at https://fly.io/","archived":false,"fork":false,"pushed_at":"2022-09-12T11:08:29.000Z","size":1546,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-13T14:24:37.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-02T08:20:57.000Z","updated_at":"2022-09-02T08:20:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc2c1afb-613d-4140-9386-ed432a513c06","html_url":"https://github.com/jonashackt/flyio-buildpacks-devfriday","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fflyio-buildpacks-devfriday","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fflyio-buildpacks-devfriday/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fflyio-buildpacks-devfriday/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fflyio-buildpacks-devfriday/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/flyio-buildpacks-devfriday/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648924,"owners_count":20972942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:26:40.640Z","updated_at":"2025-10-24T19:15:34.487Z","avatar_url":"https://github.com/jonashackt.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# flyio-buildpacks-devfriday\nHaving a look at https://fly.io/\n\n## Why?\n\nIn late August Heroku announced their cancellation of their free plan for Heroku Dynos, Heroku Postgres and Heroku Data for Redis: https://blog.heroku.com/next-chapter\n\nLooking at my Heroku dashboard there's also a new warning now stating that I need to upgrade to a paid plan for my apps before November 28th.\n\n![heroku-dashboard-cancelling-free-dynos-postgres-redis](screenshots/heroku-dashboard-cancelling-free-dynos-postgres-redis.png)\n\nI always loved Heroku for it's simplicity and used it in a lot of my blog posts, where I used it to deploy my example projects on GitHub in a super comprehensive way. I even dedicated some posts solely to Heroku https://blog.codecentric.de/en/2019/08/spring-boot-heroku-docker-jdk11/ and some of my best voted stackoverflow answers feature Heroku as well (e.g. \"Connecting to Heroku Postgres from Spring Boot\" https://stackoverflow.com/a/49978310/4964553).\n\nFinally I often introduced Heroku to my students in my lectures at University of Applied Sciences Erfurt or Bauhaus University Weimar, where all the students had a running app (in Heroku) at the end of the first lessons.\n\n\n## Fly.io to the rescue - but only with Buildpack support!\n\nSo what alternatives do we have? On a occasional team Friday some weeks ago my colleague Daniel entered the discussion about Heroku alternatives with: why not use https://fly.io/ ?! Ok, I said - never heard of it. But does it support Buildpacks? I asked him. Since Heroku is the inventor of Cloud Native Buildpacks and they belong to my standard toolbelt for around 2 years now https://blog.codecentric.de/en/2020/11/buildpacks-spring-boot/ I really don't want to miss them again. And yes, Fly.io seems to support Buildpacks https://fly.io/blog/deno-on-fly-using-buildpacks/. So why not start a small Dev Friday and have a look at fly.io in detail? My colleague Andreas started using a Go project, I opted for a Spring Boot based project https://github.com/jonashackt/microservice-api-spring-boot .\n\n\n## HowTo\n\nSo why not start using fly.io by checking out their hands-on guide at https://fly.io/docs/hands-on/\n\n\n### Install flyctl\n\nhttps://fly.io/docs/hands-on/install-flyctl/\n\nOn a Mac install flyctl via brew:\n\n```shell\nbrew install flyctl\n```\n\n\n### Signup or login to fly.io\n\nhttps://fly.io/docs/hands-on/sign-up/ or https://fly.io/docs/hands-on/sign-in/\n\n```shell\nfly auth signup\n```\n\n![signup-to-flyio](screenshots/signup-to-flyio.png)\n\n\n\n### Build example Spring Boot app with Paketo\n\nAs stated in https://fly.io/docs/hands-on/launch-app/\n\n\u003e Fly.io allows you to deploy any kind of app as long as it is packaged in a Docker image. That also means you can just deploy a Docker image and as it happens we have one ready to go in flyio/hellofly:latest.\n\nThat means you can use the proposed command `flyctl launch --image flyio/hellofly:latest` - but this would only launch a pre-build app based on the fly.io image flyio/hellofly https://hub.docker.com/r/flyio/hellofly\n\nBut as we want to use our own Spring Boot project at https://github.com/jonashackt/microservice-api-spring-boot we need to create a Docker image first. \n\nThat's easy using Cloud Native Buildpack support in Spring Boot https://blog.codecentric.de/en/2020/11/buildpacks-spring-boot/. Via Maven there's the `spring-boot:build-image` goal. Since fly CLI `launch --image` command cannont deploy a Docker image that wasn't published to a dedicated registry before, we also need to publish our image. With Maven there would be the `-Dspring-boot.build-image.publish` parameter as stated in the docs https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#build-image.examples.publish - but we also would have to configure a `\u003cpublishRegistry\u003e` tag inside our `pom.xml`.\n\nBut using pack CLI https://buildpacks.io/docs/tools/pack/ directly makes that a lot easier. With pack we can re-use our login to the Docker registry we want to publish to on the command line. And as the Docker Hub introduced a rate limiting I always love to use the GitHub Container Registry in my projects https://blog.codecentric.de/en/2021/03/github-container-registry/. Be sure to have done a login to GitHub Container Registry https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry before running the following pack CLI command to build our Spring Boot app into a Docker image: \n\n```shell\npack build ghcr.io/jonashackt/microservice-api-spring-boot:latest \\\n    --builder paketobuildpacks/builder:base \\\n    --path . \\\n    --publish\n```\n\nHaving a local Docker daemon running this should bundle our project into a Dockerfile like this:\n\n```shell\n...\nSaving ghcr.io/jonashackt/microservice-api-spring-boot:latest...\n*** Images (sha256:59f2bf1f186f6d837d211c544dfbc342817ebb94f9776e918973a0ebcc2a4163):\n      ghcr.io/jonashackt/microservice-api-spring-boot:latest\nReusing cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'\nReusing cache layer 'paketo-buildpacks/syft:syft'\nReusing cache layer 'paketo-buildpacks/maven:application'\nReusing cache layer 'paketo-buildpacks/maven:cache'\nReusing cache layer 'paketo-buildpacks/maven:maven'\nReusing cache layer 'cache.sbom'\nSuccessfully built image ghcr.io/jonashackt/microservice-api-spring-boot:latest\n```\n\nHaving a look into the package view of our repository we should be able to see the new image published:\n\n![github-cr-package](screenshots/github-cr-package.png)\n\n\nNow let's launch our fly.io app using `flyctl`:\n\n```shell\nfly launch --image ghcr.io/jonashackt/microservice-api-spring-boot:latest\n```\n\n\nBut looking into our fly.io dashboard we may see an error...\n\n\n\n### Alternative image building: Configure Buildpacks support for Spring Boot in fly.io\n\nAs an alternative to using Paketo and pack CLI yourself you can even hand that one over to fly CLI. But as opposed to what's stated in the docs https://fly.io/docs/reference/configuration/#the-build-section we do not need to add a `buildpacks` configuration to our `fly.toml`.\n\nInstead we simply override the generated `image` configuration inside the `fly.toml`:\n\n```toml\n[build]\n  image = \"ghcr.io/jonashackt/microservice-api-spring-boot:latest\"\n```\n\nand simply use the `builder` tag only like this (as stated in this so answer https://stackoverflow.com/a/73688179/4964553):\n\n```toml\n[build]\n  builder = \"paketobuildpacks/builder:base\"\n```\n\nNow fly CLI will build your app using Cloud Native Buildpacks without you requiring to issue pack CLI commands. And it even publishes the image to the fly.io Docker registry at registry.fly.io/microservice-api-spring-boot and deploy your app correctly.\n\n\n\n\n### More RAM please!\n\nOur Spring Boot app wasn't deployed successfully sadly. Having a look into the `Monitoring` of our app at https://fly.io/apps/microservice-api-spring-boot/monitoring we should see the problem leading to a `error unable to calculate memory configuration` error:\n\n```shell\n...\n 2022-09-12T09:55:32.686 runner[effc34fc] fra [info] Starting virtual machine\n2022-09-12T09:55:32.854 app[effc34fc] fra [info] Starting init (commit: 249766e)...\n2022-09-12T09:55:32.870 app[effc34fc] fra [info] Preparing to run: `/cnb/process/web` as 1000\n2022-09-12T09:55:32.881 app[effc34fc] fra [info] 2022/09/12 09:55:32 listening on [fdaa:0:938e:a7b:a992:effc:34fc:2]:22 (DNS: [fdaa::3]:53)\n2022-09-12T09:55:32.921 app[effc34fc] fra [info] Setting Active Processor Count to 1\n2022-09-12T09:55:33.006 app[effc34fc] fra [info] Calculating JVM memory based on 194456K available memory\n2022-09-12T09:55:33.006 app[effc34fc] fra [info] For more information on this calculation, see https://paketo.io/docs/reference/java-reference/#memory-calculator\n2022-09-12T09:55:33.006 app[effc34fc] fra [info] unable to calculate memory configuration\n2022-09-12T09:55:33.006 app[effc34fc] fra [info] fixed memory regions require 637219K which is greater than 194456K available for allocation: -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=125219K, -XX:ReservedCodeCacheSize=240M, -Xss1M * 250 threads\n2022-09-12T09:55:33.006 app[effc34fc] fra [info] ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1\n2022-09-12T09:55:33.875 app[effc34fc] fra [info] Starting clean up. \n```\n\nOur JVM-based app doesn't seem to have enough memory.\n\nBut we can fix that and give our app more memory [as stated here](https://community.fly.io/t/out-of-memory-restarts/1629/3): \n\n```shell\nfly scale memory 1024\n```\n\nThis should get us a green running Spring Boot app in the fly.io dashboard:\n\n![fly-io-spring-boot-app-running-the-first-time](screenshots/fly-io-spring-boot-app-running-the-first-time.png)\n\n\n__WARNING:__ This will get our Spring Boot app running on fly.io - but will also kick us out of the free plan we wanted in the first place when switching over from Heroku! The pricing docs tell us https://fly.io/docs/about/pricing/ that you the following for free:\n\n\u003e Resources included for free:\n\n    Up to 3 shared-cpu-1x 256mb VMs \n    3GB persistent volume storage (total)\n    160GB outbound data transfer \n\nThat means upgrading the memory to `1024` will cost us $0.0000022/s or $5.70 a month. But maybe we can reduce that memory consumption back to less than 256mbs later again?\n\n\n\n### Access our Spring Boot app on fly.io\n\nOur Spring Boot app is now running on fly.io without errors. We can also click on the generated hostname microservice-api-spring-boot.fly.dev - but that won't open up our app.\n\nThere are two reasons for that. First we need to tell fly.io on which port our Spring Boot app want's to be accessed. The port is defined inside the [application.properties](https://github.com/jonashackt/microservice-api-spring-boot/blob/main/src/main/resources/application.properties) via `server.port=8098`.\n\nNow we need to head over to the generated `fly.toml` in the root directory of our project and change the app's port as stated in the docs https://fly.io/docs/reference/configuration/#the-services-sections\n\n```toml\n[[services]]\n  http_checks = []\n  internal_port = 8098\n```\n\nRight inside the `fly.toml` we also need to delete the `force_https = true` configuration inside the `[[services.ports]]` section. No fear this won't deactivate https in any way, but will enable us to access our Spring Boot app.\n\n```toml\n  [[services.ports]]\n    # force_https = true\n    handlers = [\"http\"]\n    port = 80\n```\n\nNow let's refresh our apps configuration by running:\n\n```shell\nfly deploy\n```\n\nFinally our app should now be accessible to the public:\n\n![fly-io-accessible-spring-boot-app](screenshots/fly-io-accessible-spring-boot-app.png)\n\nJust access it at https://microservice-api-spring-boot.fly.dev/api/hello\n\n![browser-app-access](screenshots/browser-app-access.png)\n\n\n\n\n\n\n\n\n\n\n\n# Links\n\n\u003e The fly launch command detects your Dockerfile and builds it. If you have Docker running locally, it builds it on your machine. If not, it builds it on a Fly build machine. Once your container is built, it's deployed!\n\nhttps://fly.io/docs/languages-and-frameworks/dockerfile/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fflyio-buildpacks-devfriday","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fflyio-buildpacks-devfriday","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fflyio-buildpacks-devfriday/lists"}