This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
H4X0RZ's profile picture

Containerization in CC ?

Started by H4X0RZ, 29 August 2016 - 08:46 PM
H4X0RZ #1
Posted 29 August 2016 - 10:46 PM
I wrote a small program which allows you to put a project (can be multifile too) into a "capsule" (which is a just a mirror of the folder content in one file. So you could share them on the forums because they contain the sourcecode in plaintext) and run the container inside a semi-sandboxed emulated FS. It also has built-in support for Glue. Because of the way I built it, there is no way for the program to modify any files on the computer so the program is state-less. It is impossible for the program to realize that it has been run before. Although I intend to add small helper functions which allow the program to read and edit a config file, or even mirror one folder between the actual FS and the emulated one.

Anyone got some input? If there's no interest, I think I shouldn't keep working on it (I already got a semi-working version of it, actually) so the community decides if this will survive now.

If you are just interested in the emulated FS, check out the ccfs drop.

Greetings,
H4X0RZ //Paul
Admicos #2
Posted 29 August 2016 - 11:13 PM
It would be great if you could package the container into a single file, so we can bundle the dependencies and just send a single file kinda like flatpak (and some others too).

But if it doesn't get "standartized" i don't see much use of something like this if people will still use the old method of making the user download multiple files on their own (or sending a installer which downloads multiple files)
Edited on 29 August 2016 - 09:13 PM
H4X0RZ #3
Posted 29 August 2016 - 11:22 PM
It would be great if you could package the container into a single file, so we can bundle the dependencies and just send a single file kinda like flatpak (and some others too).

But if it doesn't get "standartized" i don't see much use of something like this if people will still use the old method of making the user download multiple files on their own (or sending a installer which downloads multiple files)

A container (the script calls them "capsules") can contain anything you want. Although it was designed to download the dependencies once you run it, not ship them inside the container. Thanks to glue and the custom FS it's guaranteed that the program always runs in the same environment though. The only thing you would have to do is to write a wrapper drop which either up- or downgrades specific CC functions so it also emulates a specific host system (which can be part of the GlueFile of your project)
Edited on 29 August 2016 - 09:23 PM
Bomb Bloke #4
Posted 30 August 2016 - 06:32 AM
I guess if I were to build something like this, I'd simply go with a straight virtual file system deal - a script which can produce an archive file out of an existing folder, which in turn can be executed to mount its contents as a virtual version of that folder (optionally read-only, optionally triggering a file autorun on mount, automatic unmount once that's done, optional "make folder appear as root", etc).

But, well, if were actually going to use such a thing, I'd've built it already…
Lupus590 #5
Posted 30 August 2016 - 08:56 AM
There's a project called ccDocker somewhere on the forums that sounded like this. (I tried to find it last night before deciding that 3AM is a good time to go to bed.)
Google managed to find it: http://www.computercraft.info/forums2/index.php?/topic/23361-virtualization-ccdocker/
Piorjade #6
Posted 18 September 2016 - 10:33 PM
Didn't oeed do something like that too? I think it was called compilr and his browser used it or something like that…
Lupus590 #7
Posted 19 September 2016 - 01:42 PM
compilr is a build system, it converts multiple files into a single file. Containers are more like sandboxes, although it still can be used to package multiple files into one, it is not designed for that use.

IIRC IRL containers were made because of the many Linux distros, you could never be sure if your app would be compatible with all of them as they each had a different environment. Containers 'bring' their environment with them, or rather bring instructions on how to recreate it. It's not quite a full virtual machine, which means it runs faster than a VM, but it's not quite running directly on its host OS as there is still the container.

If running a program on another computer is camping and a VM is bringing the house with you when you go camping, then containers are the caravans.
H4X0RZ #8
Posted 19 September 2016 - 05:08 PM
Didn't oeed do something like that too? I think it was called compilr and his browser used it or something like that…

https://github.com/TheFreakLord/Capsule/blob/master/capsule.lua
https://glue-client.herokuapp.com/drop/ccfs/1

These are the two main "components" Capsule consists out of right now. If you're interested you can take a look at the source (the most interesting part happens in CCFS and in line 119 to 148 in capsule.lua)