3
kiki
214d

Genuine question
You're given a server with the latest Ubuntu. You can't install any deps, and you can't use docker. Your goal is to write a REST API backend that can store/retrieve data persistently, ideally with a SQL-like language. Bonus points if you can figure out a reverse-proxy.
What would you do?
I'm obsessed with an idea of having some kind of codebase that doesn't include binary files and that I can just ssh over to a fresh server, and it would work instantly

Comments
  • 0
    java + sqlite or H2 :)

    you don't have to install anything for either of those. Just scp the java app in along with the java binaries and fire it up
  • 0
    @netikras nah, no binaries. Perl or python then?
  • 2
    @kiki depends on what's available on the server and what skills you've got.

    I think I'd go with Python. Although I miss playing with Perl too...
  • 3
    I know! Do it with bash!!
  • 2
    @kiki i remember building some backend in python, because the only thing i had available is a locally running centos instance, that is encapsulated from the internet, managing some internal network.

    it worked quite well btw. I pesonally would have used something different, but it was a requirement
  • 1
    @thebiochemic just what I need, thanks. I'm not quite a fan of python, that's why I'm asking for other options

    how did you handle data storage/reverse proxying?
  • 3
    All this post tells me is if I'm ever responsible for a distro it should include either a c++ compiler toolchain, openjdk, ghc or another developer toolkit for a useful language in case anyone is ever stranded on an instance.
  • 1
    @netikras perl? lmao PERL? REALLY??? All I have to say to you is: one of us, one of us one of us one of us one of us one of us
  • 3
    kiki, Perl or Python would work well (to that extend you can be hardcore about it and use bash, but that is only for masochists)

    The only thing that would make this complex is that there is no default installed database on linux distros, you could, potentially if you wanted, to generate a file based approach in which you keep everything on a local file that contains textual db structures in it, very much not recommended. For a reverse proxy there are packages for those, but you said no packages. It would have to be configured with your preferred stack.

    That sounds hardcore
  • 0
    @lorentz jdk can be simply copied in. It does not require any installation/prep work
  • 1
    @AleCx04 if I recall well, you did smth with perl this year, rite?

    As for db -- sqlite? No need to install
  • 1
    @netikras yeah man! If i think it is what I talked about before, it is the glue script inside of a project that makes specific reports for the organization.

    I think it is the one in which one of my employees was raging because I did it in perl and he didn't know perl lol.

    And i didn't know sqlite was already a default! that is pretty bomb.
  • 1
    @kiki i think is used the cgi lib in Python itself and for routing and stuff i used apache (can't recommend nowadays, but i was most comfortable with it at the time. nginx is probably the way to go nowadays) and for data storage i used something mysql, i dont remember what it was exactly tbh. It worked quite decent tho. Nowadays i can also recommend sqlite for smaller applications.

    I think the reason was because it was nicely testable via xampp stack back then. i remember the py version was older than 2.7
  • 0
    @AleCx04 IDK if it's installed by default, but it can be easily copied in -- no need for any installations.
  • 1
    @netikras In industrial environments and companies that aren't quite sure what security is but want to have all of it, it's annoyingly common to have only a direct keyboard (+ maybe mouse) interface with a remote machine without any means of file transfer or local keyboard macros.
  • 3
    Let's get back to topic.

    If it's solely a reverse proxy (NOT a webserver)… HAProxy.

    It's made for this.

    "You can't install any deps".

    This is kinda wrong (and making HAProxy impossible).

    What are we talking about... you don't want to install dependencies and not using docker?

    Create tarballs.

    It's as simple as that.

    chroot for installing all dependencies, tarballing whole root filesystem.

    Voila. You created your own distribution.

    It's messy, but doable.

    Depending on what language tickles your fetish, you don't even need to create a full root tarball.

    The default user of a common server install can pretty much create its own virtual environment - what homebrew under Mac does, is pretty common in many languages.

    Pythons PipEnv.

    Java JDK.

    Rust.

    PHP.

    Go.

    As long as the dependencies exist on the system, everything works out pretty much without modification.

    Rust has cargo, Go uses static binaries, PHP has composer, Java Maven -/ Gradle.

    Gradle takes it so far, you have the full JVM at your hand writing buildscripts (for good or for worse).

    No dependencies needed.

    As Go and Rust create static binaries, they run without dependencies.

    Caddy was Go, Traefik too if I remember correctly. Both should run without dependencies.

    Webservers are integrated into most languages by default, no dependencies needed.

    But imho you're trying to solve a problem already solved. :-)

    I'd rather go for Ubuntu rootfs / basefs (non bootable minimal tarball) or similar things in other distributions and handtailor a VM.

    https://wiki.ubuntu.com/Base

    Many ISPs allow tarballs or similar formats for custom creation of machines / servers / XY

    Which makes things WAY easier.

    Guess that's not what your intention was, but .... just as a sidenote.
  • 0
    @IntrusionCM wow, thanks! A lot to unpack
  • 1
    @kiki

    Python will work .

    http.server, socketserver, sqlite3, and json are part of Python’s standard library, so they come pre-installed with Python. You don’t need to install any additional dependencies to use them. as far as i know ..
Add Comment