How to deploy spring app

Hello! I’m new to fly. I want to deploy my spring-boot app with postgres. I wrote a dockerfile of spring app

FROM openjdk:17
COPY target/app-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar", "/app.jar"]

I started a postgres service in succesfully, copied connection address and password and set it to secrets in flyctl flyctl secrets set DATABASE_URL=...
I pushed my docker image to docker hub and wrote in [build] section of fly.toml:

  builder = "paketobuildpacks/builder:base"
  image= "myimage..."

But it was saying
Failed to provision a Sentry project for this app. Use `fly ext sentry create` to try again. ERROR: input:3: createAddOn We need your payment information to continue! Add a credit card or buy credit:".
I deleted these lines and again launched flyctl deploy and it seems that it worked out, it used local image instead I guess. But looking into app logs it says the url that was provided to me when I started postgres can't be accepted by JDBC, the error says and the app stopped because of the retries. I updated the secret in the secrets page, trying another jdbc url, and trying to restart the app, but it says could not reserve resource for machine: insufficient memory available to fulfill request. I’m trying to set memory limit to 256 by saying flyctl scale memory 256 but it’s also gives the same error. Is it because postgres already taking up these 256 mbs? I thought it’s 256 to one app? What could be wrong?
UPD: So I figured out postgres is not taking up memory, but it’s still not running, I’m restarting it simply with flyctl deploy. Even making it ENTRYPOINT ["java","-XX:MaxRAM=70M", "-jar", "/app.jar"] doesn’t help. But locally 70m is enough to run my app. What could be the problem? How do I check how much ram is actually used?

Answer: adding swap_size_mb = 512 in fly.tml file helped

How do I check how much RAM my app uses? I want to give it as much as possible ram now.

Once you all is deployed you can check the memory section of the metrics dashboard. You could also ‘fly ssh console’

This would put you on the VM and allow you to research there.

Good luck.

FYI the default is 1 shared cpu and 256 mb of ram on the VM.

You can scale both of these up if needed through the fly cli.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.