python-discord / snekbox

Easy, safe evaluation of arbitrary Python code
https://pythondiscord.com
MIT License
214 stars 39 forks source link

Is it possible to mount files directly into the docker container #176

Closed maxkoretskyi closed 1 year ago

maxkoretskyi commented 1 year ago

So I can create files that will be referenced in a python script like this using HTTP:

{
    "args": ["main.py"],
    "files": [
        {
            "path": "main.py",
            "content": "d2l0aCBvcGVuKCJ...="
        },
        {
            "path": "source.txt",
            "content": "c3VwZXIgYWR2YW...="
        }
    ]
}

this works great, but the files I need to process are in tens of gigabytes. Is there any way for me to mount them directly into the container so that I won't be using HTTP to transfer all that data?

MarkKoz commented 1 year ago

Hey, I believe snekbox can support your use case. You can mount your files as a Docker volume using Docker's CLI options when starting a container. You'll need a custom NsJail configuration to mount your volume into the jailed process. Using a custom NsJail configuration also requires a mount with Docker (or you can build your own image); you will need to mount it to /snekbox/config/snekbox.cfg within the container.

If you make this mount read-write rather than read-only, keep in mind that these files will be accessible to all eval requests.

MarkKoz commented 1 year ago

Going to close this issue since I believe I've answered the question, and there's been no response for a few weeks. If you have follow-up questions, feel free to leave them here.