r/SpringBoot • • Feb 17 '24

Easiest way yo deploy a spring boot app in production

Hi everyone,

I am new to web development. This is my first commercial project.

I am working on a startup idea that requires a landing page, an email capture page and a basic thank you page. Later one, I might add a blog and a selling page.

I am familiar with java for past experience with javafx desktop app. My reading suggested that Spring boot is the most popular framework for my need. I have coded the web app and it is working on my computer.

I want to deploy it online at minimal cost. I started reading about deployment and I realised that it is a whole new area of knowledge.

Any idea how I can go with this? What are the most popular and easiest solution for startups?

Thanks

31 Upvotes

21 comments sorted by

18

u/g00glen00b Feb 17 '24

To be fair, if you only have a few static pages and a form (right now), then I would consider not using Spring Boot. In stead, you could create a few HTML pages (or use a static site generator, even though that's overkill at this point) and deploy them on a Content Delivery Network/CDN.

There are several CDN's out there that have a basic free plan, so you only pay for your domain name. Some of those come with basic serverless functions (like Cloudflare) or form handling (like Netlify), so you could even create the e-mail capture page with their free plan.

-2

u/LouGarret76 Feb 17 '24

Hi can you elaborate more on this? Spring boot seemed to be an obvious choiece when I started my research. What are CDN ?

4

u/g00glen00b Feb 17 '24 edited Feb 17 '24

The problem with any app framework, including Spring Boot is that you'll pay for the time your app is running. Either you run is 24/7 and very likely pay for it, or you scale to zero, but then you have other issues such as improving startup times and so on.

And so far, you haven't told us anything that really requires an application to be running all the time. Most of the things you described are pretty static (like a landing page, a form to collect emails, or a blog).

So, that's where a Content Delivery Network shines. On a CDN, you basically put your static web assets (HTML, client-side JavaScript, CSS, images, ...) and then they get cached all across the globe and served.

The pricing model of a CDN is completely different, rather than paying to keep something in the air 24/7, you pay for number of requests served, or bandwidth or the amount of data stored. They usually have a big free tier though, so if you host a small landing webpage, you often don't have to pay anything.

To give you an idea, I have a blog + landing page + contact form which are developed using a static site generator framework (= a framework that renders all content beforehand so you end up with a bunch of HTML files), and I deploy those for free on Netlify, and previously did the same on Cloudflare.

Just so you know, I like Spring Boot and I love developing with it, but I don't think this is a good use case for it, certainly not if you're looking for a cheap way to host.

1

u/LouGarret76 Feb 17 '24

I am interested to know more. How do you collect the data from the contact form ?

2

u/g00glen00b Feb 17 '24

I use Netlify Forms. Since it's a contact form, I'll let Netlify forward any of those messages to my e-mail, but you can also choose to download a CSV if you're just interested in the data. First 100 submissions every month are free.

Before Netlify, I used Cloudflare Pages, and they don't have a "forms system", but they do allow you to write some basic functions (in JavaScript) and there the first 100k requests per day are free.

But if you're building a thing like a newsletter or something, it might be even cheaper or easier if you integrate with something like SendGrid, which also has a free plan.

3

u/No-Possibility-6454 Feb 17 '24

Hey buddy I wanted to ask about using aws as a student. They say it has hidden charges and I will get billed suddenly(I want to use file upload service like s3 and deploy my spring boot docker image) can I do this in free without getting any charges. Also How can I make sure some one never spams my server so I dont cross free tier limits

(I am beginner in deployment , cloud Also new on reddit XD :)

3

u/SuspiciousElgamal Feb 17 '24

For java application I'd go with heroku. It's really intuitive and in a few minutes your application will be up and running

5

u/asdspartadsa Feb 17 '24

Absolutely easiest? Rent a server, copy your jar file on it, and run it. Otherwise, the other commenter's suggestion is more elegant.

2

u/ringofgerms Feb 17 '24

The easiest thing would be to use a cloud provider which offers a service where you more or less only need to upload a jar file (or docker image. but that's a tiny bit more complicated). For example Amazon has AWS Elastic Beanstalk, Microsoft has Azure App Service. I would take a look into those offerings and see if it fits your budget. Your requirements are pretty low so you can probably find a decent offer.

The Spring Boot documentation has some info here: https://docs.spring.io/spring-boot/docs/current/reference/html/deployment.html#deployment

2

u/WaferIndependent7601 Feb 17 '24

There should be services around where you can create anything you need. Spring boot is overkill here, so just buy what you need. Will be cheaper

2

u/jaktrik Feb 17 '24

I think you should explore Render they provide free hosting for hobby and have the option to deploy using Docker from your git repository.

Once you are moving to production you can use digital ocean or explore giant like AWS and Azure

1

u/Thatpersiankid Feb 18 '24

I would use railway or heroku

0

u/[deleted] Feb 17 '24

[deleted]

1

u/LouGarret76 Feb 17 '24

What is that?

2

u/[deleted] Feb 17 '24

[removed] — view removed comment

1

u/LouGarret76 Feb 17 '24

I agree that most of the pages except from the contact form are static. I do need a database to collect the email and message from the contact form. That is what let me to spring boot in the first place.

1

u/rootException Feb 17 '24

My two cents - you can use Supabase as the database and something like SvelteKit to deploy to Vercel. Really dig it.

I've been a Java dev since the 90s and SK+Vercel+Supabase really impressed me.