Hi everyone,
I see that java 1.8 is available in Glitch.
Can I run a SpringBoot-app in Glitch?
For example, I would like to expose APIs, implemented in SpringBoot (instead of Node.js), via Glitch, is it possible?
yeah, there is Java, and you can serve your app from it. there’s no official support provided for it, so you’ll probably have to do some amount of configuration for it on your own.
have you taken a look at how to write a package.json “start” script to run any command?
Thanks for the quick reply.
Yes, I see by default package,json runs node server.js
. I guess If I replace it, for example, with java -jar spring-boot-app.jar
then SpringBoot app should be started.
I am wandering how the app will start up when a container sleeps and then wakes up: does package.json trigger a start script every time when a container wakes up?
when waking up a project from sleep, glitch does the following:
- start project container
- run package.json
install
script - run package.json
start
script - wait for a program to listen to the port in $PORT or some other common port
Thanks for details.
When a project container is starting up - does the container always has the same IP-address?
In package.json I don’t see install
script but only start
:
"scripts": {
"start": "node server.js"
},
Is install
optional?
What does it suppose to do?
ip address: docs don’t say it has the same IP address. in practice it’s not directly connected to the Internet. a reverse proxy forwards incoming http requests to your project container.
install script missing: yeah it’s optional. if you need it, you can add it there. but if all your dependencies are saved in the project itself, you should be fine without one
Thanks, this is clear.
How do outbound requests work?
For example, my project makes an outbound HTTP request to an external Rest API. That API has some access policies and needs to whitelist my IP-address. Which IP-address should I provide them?
outbound requests are sent from the project container’s host machine, which glitch doesn’t give you control over. they just somehow choose a bunch of projects to place on a host machine for however long.
if you’re able to use a different kind of authentication with the access control system, you can set up secrets in a .env file and put that in the request
Hi @wh0 ,
I see that only java8 is currently available in a container.
This is quite old one, can you upgrade java version up to 17 or 21 (21 is the lates LTS version)
I tried to install the java21 into my /app
folder, but there is not enough space there. I cannot install even JRE - it requires ~130M.
Can you add extra space?
yeah I’m currently working around this by putting a prebuilt copy of java on github releases and downloading that into /tmp on project startup. let me make one with 21.
this adds a while to the project startup though, like two minutes
Ah, good to know!
Any estimation when will it be available for everyone? )
we’re waiting on a project container OS update to make a lot of stuff like newer JDK more readily available.
no estimate posted though