:wave::skin-tone-2: Free hosting question, or lac...
# server
j
👋🏻 Free hosting question, or lack thereof I am working with @Piotr Krzemiński on the #github-workflows-kt open source project, that wants to free the world to have to write YAML for their GitHub Actions. We have a YAML to Kotlin converter that works fine locally. But we are stuck because we would like to host it as a JVM server, and all free hosting plans are gone thanks to all those crypto scammers. For an open source project it’s annoying to have to pay every month for one little converter like that. Can you think of a work-around? like having a nice sponsor, gaining startup credits somewhere or something like that
d
v
Who said that all free services are gone?
And several others too still provide free hosting
For small needs
j
@Nikky told me he was traumatized by Oracle’s bad UX
d
I mean you can use lambda to get you a reasonable amount of free calls - it's not quick for sure, but it will work
v
bad UX != not free anymore 😄
But I never used the oracle cloud
d
I can confirm that it suuuuuuccccckkkks
😂 1
😉
j
Fly sounds interesting, do you have a good experience with it David?
v
j
Fly is really good, I would recommend this hosting provider!
d
@jmfayard apart from developing the serverless stuff for http4k, no I don't. TBH if it's supported by pulumi, then it's probably reasonably hands off.
j
Amazing, thanks to all
👌 1
d
Fly is more like a heroku-type deal - it's more of a PaaS than AWS etc.
j
😅 1
d
@jmfayard are you just in search of "an API on the internet"?
j
We need a webtool like this, with YAML from GitHub actions on the right, and Kotlin in the left side instead of JSON, and the converting being already written in Kotlin. Goal is that the user doesn’t need to install the converter. https://www.json2yaml.com/
Might be a good occasion to try out http4k to be honest
d
that's always the correct answer... 😉
c
If you want to go the bootleg route, I'm sure you can use the Kotlin Playground for that 😅 Provide a link to the user with the entire code and a "replace this string by your yaml file"
d
TBH, if you can afford $7 a month then you can use the basic plan on heroku. that's what we use for the http4k toolbox and it works pretty well.
👍 1
j
I use hetzner for projects that i need to be very cheap. they have a EUR4/month.
c
If it's for the github-workflows project, why do you need an external service though? Presumably, the user has GitHub Actions enabled, why not just use that?
j
The user should need to to download the project and a run a weird Gradle command to get started imho
Copy paste your YAML, download the KTS script, commit
v
You confused people my mixing up sides above. 😉 You said you want it like json-to-yaml, with Kotlin on the left. Not with Yaml on the left and producing the Kotling script. 🙂
If you assume that uses have Kotlin ready to use, you could though just provide a small bootstrapping
.main.kts
instead, that you download to your workflows directory and execute. That will then convert all Yaml files in there and optionally destroy itself afterwards. This way you don't need any online service at all.
Or as a function within the project or in a separate artifact, so that a new user creates a new
test.main.kts
script for a
test.yaml
, copies in a 2-line script which consist of the
@Depend
and one bootstrap line, then executes it which will read and convert the Yaml, and write the result to itself. (If that works properly for example on Windows)
p
another idea: an IDE plugin that would perform the whole conversion using a single action. Disadvantage: it’s IDE-dependent, and what Björn proposed above would work even with bare Kotlin compiler + well, JRE
d
IntelliJ plugin development .... 😱 . 😂
🤷 1
🎉 2
p
tried it once, https://github.com/JetBrains/intellij-platform-plugin-template does a pretty good job by bootstrapping stuff 🙂
not pushing too much in this direction, though. Maybe an easy-to-install CLI would also do the job, see Create a Kotlin CLI to improve overall developer workflow. Maany ways to approach this
d
The APIs for plugin development (last time I tried it) weren't exactly a joy to work with. Plus writing tests for it is pretty hard
👍 2
p
@jmfayard have you considered free tier in e.g. AWS? https://aws.amazon.com/lambda/ if we could just disable the service once we exceed 1 million YAML -> Kotlin conversions per month (😂 ), it could work
j
Its a great discussion... about how to host a "simple" service. AWS gets surprisingly complex very quickly. IAM + STS, 2FA, Cloudwatch, Pulumi, API GW etc etc. Don't get me wrong, I've run some big services on AWS, but there is a big surface area. Heroku was good. Fly, never tried...
p
yeah, I have some production-grade experience with AWS as well, but this simple service would allow us to remove many components you mention form the picture. Like auth, probably not needed. Metrics - nice to have, not strictly needed. API gateway - yeah, it’s a question if the lambda’s “internal-looking” URL would be acceptable and if it can change at any time or not
j
A while ago I was searching for hostings with free tiers myself, and I found these: • https://render.comhttps://railway.apphttps://fly.io Also, DigitalOcean have an Open Source sponsoring plan which gives you 5$/month if your project has 500 stars on GitHub, if I recall correctly.
🙌 2
d
With lambda it's the cold start that's problematic. Of course, if you go with graalvm then you can elliminate some of that, but if you're doing reflectomagic then that's awkward to setup. If you used Moshi + reading into maps then that would be easier because there isn't reflection 🙂
☝️ 1
p
I claim even 30-second cold start for this particular use case is bearable
or, the library will get insanely popular and the service will be always “warm” 👀 😂 then we’ll need a sponsor
d
We have a total guide to deploy http4k to lambda from scratch with graalvm here 🙂
🙌 1
e
Can't you run the Yaml -> kotlin conversion script as Kotlin/JS which you just embed? Then it'll run in the JS engine in the browser? 🙂
p
it would require rewriting typesafegithub/github-workflows-kt/script-generator which currently depends on JVM in several ways (KotlinPoet and kaml are JVM-only, plus we use JVM reflection). But yeah, despite the effort, it’s still an option
a
personally I gave up on trying to wrangle with online hosting and I bought a small Intel NUC for hosting my projects at home, and I use Docker Compose + Traefik. It’s really interesting reading about the options though.
wacky idea: what about writing a GitHub Action that will create a PR with the converted files?
p
we thought of that - the question is how would look like from user’s perspective. They would need to add a temporary GH workflow right?
a
yes, so it would be more work for users. Good point. I was thinking about how Renovate works - that can make PRs without a workflow. But I guess that’s running on a server! Plus it requires allowing access and configuring permissions… which is probably too much hassle.
p
yes, for Renovate it’s one-time configuration for long-term benefits, here we want to have a tool for one-time use
j
I think nothing beats a web tool for trying out something quickly.
👍 1
a
agreed
j
Keep in mind that not all our potential users are kotlin/Java devs. Everyone who hates to code in YAML is welcome. I would gladly use the project if it used typescript/python/whatever
d
In order to create a PR you need a token with write access to the entire repo. that's challenging from a security perspective
p
true, we need something less invasive. A Web app would be great UX-wise
v
In order to create a PR you need a token with write access to the entire repo. that's challenging from a security perspective
While I also think a workflow is bad for a one-time action, this point should not be true?
GITHUB_TOKEN
should be able to create a PR as long as it is not running a pull-request build, shouldn't it?
p
I know about these settings for Actions. The checkbox is disabled by default
By default it does have read/write, but in many environments that will be locked down
👍 1
v
ah, ok
j
you can clone it and make an upstream PR? (not tried it, just a guess)
p
@jmfayard how about trying to apply for https://www.digitalocean.com/open-source/credits-for-projects? they mention 100+ stars for “tier: testing” (whatever it means)
v
I guess the tier just identifies the amount of credit you get. With 60$ per year that is 5$ per month. That's enough for one droplet of smallest size (4$ per month) running 24/7 which probably is enough for your use-case. But if you for example would need a database instance too, or mutliple load-balanced instances or similar, the testing tier would not give you enough credit.
m
I've been using Google app engine for small apps. The UX sucks and you get "only" 256MB of RAM which the JVM will happilly use to store metaspace and what not. But it's free has a free tier and it works
d
256Mb is plenty for an http4k app BTW 😉 .
🙌 1
Well - 256m of heap - 🙂
m
Nice!
My Spring Boot app regularly reboots because of Oom but I have never really investigated the reasons why
It "just" reboots, no pb😅
😇 1
j
one of the very nice, and somewhat underappreciated things that http4k does, is start up really fast! - 100ms for a production server is just normal - even with all the things.
for me this is a huge - when you deploy a bunch of things, you can get to a fully deployed state so quickly, even waiting for the health checks to pass.
also, dev iteration time ftw.
p
before we start enjoying the fast startup, we need a place to deploy the app 😉
m
If you want an example of deploying to appengine, I have one here. There's ok-ish Gradle support so you can deploy quite easily
d
@Piotr Krzemiński you may well be able to take advantage of a low-RAM freebie - not enough for a cryptominer but enough for you maybe 🙂
👍 1
you could even host react stuff and serve it statically from the classpath if you wanted to do an entire JS toolchain.
(but handlebars would probably do!)
v
An entire JS toolchain that uses JVM-only dependencies? Impressive, how to do that? 😄
p
@Vampire GWT! sorry, it works only with Java
🙈 2
d
if you wanted to do "log in with github", you could also maybe use the API to let the use select projects or do it automatically by looking up using the API
GWT!
#shudders
p
I think we need a summary of options here, with pros and cons; this thread is/was a great brainstorming session. @jmfayard let me know if you want to prepare one, otherwise I’ll probably do it
j
ok will try
How to host a simple JVM app for free? A simple question that needed a surprisingly good brainstorming question to answer. https://github.com/typesafegithub/github-workflows-kt/issues/571 Thanks to @Vampire @dave @Vampire @Piotr Krzemiński @James Richardson and all those that I forgot
d
feel free to tag me as
@daviddenton
and james as
@time4tea
in that issue btw 🙂
j
also shared in #feed because cool discussion
👍 3
p
I feel attracted to trying out http4k on this use case :)
j
Me too but that's not my fault, they made such a great presentation at kotlinconf
d
@jmfayard I'm afraid that was a while ago... too long! But you also only have to wait 8 days to see the sequel. It's been a while in the making and we can promise you something that may well make your head 🤯. 😉
e
if porting to JS is too much work, there's always things like https://leaningtech.com/cheerpj/ or https://www.teavm.org/. then your JVM bytecode runs on the client and you only need static hosting
v
o_O
e
v
Interesting, but I guess it also has limitations, like reflection not working?
e
CheerpJ supports reflection
v
Nice, TIL
p
what’s the catch? why isn’t it more popular? is it free to use? 🤔
e
CheerpJ isn't free. TeaVM is, but has some limitations
👍 1
v
At least TeaVM seems to only support certain APIs
e
it's enough enough for some Kotlin projects
v
Yeah, definitely worth a try. TeaVM is ASLv2 licensed
From the pricing page it looks like CheerpJ needs a hosted runtime though, either self-hosted or cloud-hosted.
💡 1
e
https://docs.leaningtech.com/cheerpj/Frequently-Asked-Questions "The CheerpJ runtime library is hosted by us on a dedicated CDN-backed domain, and we invite users to link to it in order to take advantage of caching and cross-application resource sharing."
actually I hadn't realized the community tier was "free"
v
Well, it says only for testing, but well, ... 😄
e
on another note, is porting to Kotlin/JS really that difficult? the only JVM dependency I see is SnakeYAML, and perhaps https://github.com/Him188/yamlkt could fill that role
p
also KotlinPoet and JVM reflection
we’re talking about porting this project
e
ah, I looked at "library" earlier
not sure what reflection you're using but https://github.com/square/kotlinpoet/issues/304 may be in the future
thank you color 2
p
thanks, I was about to create the request myself. I’ve added a comment
e
kotlinpoet is usually discussed in #squarelibraries
p