engineer-man/piston

PISTON_REPO_URL value when selfhosted

Closed this issue · 3 comments

Hi
I'm trying to host the piston in my own server which do not have connectivity to external world. I have installed required dependencies -

  • Docker
  • Docker Compose
  • Node JS 20
  1. Downloaded the piston-master zip to my local laptop from github and copied it into the server.
  2. Pulled the ghcr.io/engineer-man/piston image in my local laptop and copied its tar to the server and loaded it.
  3. Started the piston_api container using the below docker-compose.yml file:-
version: '3.2'

services:
    api:
        image: ghcr.io/engineer-man/piston
        container_name: piston_api
        restart: always
        ports:
            - 2000:2000
        volumes:
            - ./data/piston/packages:/piston/packages
        tmpfs:
            - /piston/jobs:exec,uid=1000,gid=1000,mode=711
            - /tmp:exec

Since the server didn't had the internet connectivity, I downloaded python package from https://github.com/engineer-man/piston/releases/download/pkgs/python-3.9.4.pkg.tar.gz in my local laptop, copied it into this server, and then extracted it into the data/piston/packages/python/3.9.4 folder which is mapped to piston/packages/python/3.9.4 inside the container.

curl -H 'Content-Type: application/json' http://localhost:2000/api/v2/runtimes returns an empty response [] and it do not consider the existing python folder inside the /piston/packages folder.

Now when I am trying to hit the curl -X POST -H 'Content-Type: application/json' -d '{"language": "python", "version": "3.9.4"}' http://localhost:2000/api/v2/runtimes endpoint of my piston container to install a package, it crashes saying reason: getaddrinfo ENOTFOUND github.com

It seems PISTON_REPO_URL is the value to tell piston_api container where to look for packages when it need to download. However, I don't want to install any new package. Just python is enough.

I can't figure out how to make piston_api stop looking outside to git and work with the packages available in the /piston/packages folder?

/cc @HexF

I created the .env file and .ppman-installed inside the data/piston/packages/python/3.9.4 and /execute and /runtimes are working now.

.env

PATH=/piston/packages/bash/5.1.0/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.

.ppman-installed

1714542933000
  • Is this the right way get it up and running in self-hosted env?
  • Server still crashes if I hit /packages api.

The packages GET endpoint sends a request to an external repo url for getting the available packages there and stating if they are installed on your Piston instance. If you don't have external connectivity and your are adding the packages manually, then there is no need for this endpoint. Or you can make your own local repo container that works like the repo container here, but with the tarballs pre-fetched

Sure
Thanks