Skip to content

python generic

A Generic Python Egg for Pterodactyl Tested with: https://github.com/Ispira/pixel-bot

Report an issue
updated
variables
9
images
8
author
parker@parkervcp.com
sha256
679d0850d1fd

Readme

Python Language Generic

This egg is designed to run any generic Python application, allowing users to pull their own Python source code from a Github repository.

There is an option to allow a user to upload their own files to run a bot.

The startup configs and commands may need changing to actually function properly.

Configuration

The server will be stuck as starting until the egg Start Configuration is modified. You have to edit the text to match something your bot will print for Pterodactyl panel to detect it as running. image

You can use arrays to have multiple different values when different bots are being used

{
  "done":[
    "change this text 1",
    "change this text 2"
  ]
}

Startup command

if [[ -d .git ]] && [[ "{{AUTO_UPDATE}}" == "1" ]]; then git pull; fi; if [[ ! -z "{{PY_PACKAGES}}" ]]; then pip install -U --prefix .local {{PY_PACKAGES}}; fi; if [[ -f /home/container/${REQUIREMENTS_FILE} ]]; then pip install -U --prefix .local -r ${REQUIREMENTS_FILE}; fi; /usr/local/bin/python /home/container/{{PY_FILE}}

The parts in blue are filled in by the panel when the server starts, from the variables below.

Docker images

  • Python 3.13 ghcr.io/ptero-eggs/yolks:python_3.13
  • Python 3.12 ghcr.io/ptero-eggs/yolks:python_3.12
  • Python 3.11 ghcr.io/ptero-eggs/yolks:python_3.11
  • Python 3.10 ghcr.io/ptero-eggs/yolks:python_3.10
  • Python 3.9 ghcr.io/ptero-eggs/yolks:python_3.9
  • Python 3.8 ghcr.io/ptero-eggs/yolks:python_3.8
  • Python 3.7 ghcr.io/ptero-eggs/yolks:python_3.7
  • Python 2.7 ghcr.io/ptero-eggs/yolks:python_2.7

Variables

9 settings

  • Git Repo Address

    Git repo to clone I.E. https://github.com/parkervcp/repo_name

    env
    GIT_ADDRESS
    default
    none
    rules
    nullable|string
    • viewable
    • editable
  • Git Branch

    What branch to pull from github. Default is blank to pull the repo default branch

    env
    BRANCH
    default
    none
    rules
    nullable|string
    • viewable
    • editable
  • User Uploaded Files

    Skip all the install stuff if you are letting a user upload files. 0 = false (default) 1 = true

    env
    USER_UPLOAD
    default
    0
    rules
    required|boolean
    • viewable
    • editable
  • Auto Update

    Pull the latest files on startup when using a GitHub repo.

    env
    AUTO_UPDATE
    default
    0
    rules
    required|boolean
    • viewable
    • editable
  • App py file

    The file that starts the App.

    env
    PY_FILE
    default
    app.py
    rules
    required|string
    • viewable
    • editable
  • Additional Python packages

    Install additional python packages. Use spaces to separate

    env
    PY_PACKAGES
    default
    none
    rules
    nullable|string
    • viewable
    • editable
  • Git Username

    Username to auth with git.

    env
    USERNAME
    default
    none
    rules
    nullable|string
    • viewable
    • editable
  • Git Access Token

    Password to use with git. It's best practice to use a Personal Access Token. https://github.com/settings/tokens https://gitlab.com/-/profile/personal_access_tokens

    env
    ACCESS_TOKEN
    default
    none
    rules
    nullable|string
    • viewable
    • editable
  • Requirements file

    if there are other requirements files to choose from.

    env
    REQUIREMENTS_FILE
    default
    requirements.txt
    rules
    required|string
    • viewable
    • editable
Installation script 70 lines container python:3.8-slim-bookworm entrypoint bash show
#!/bin/bash
# Python App Installation Script
#
# Server Files: /mnt/server
apt update
apt install -y git curl jq file unzip make gcc g++ libtool

mkdir -p /mnt/server
cd /mnt/server

if [ "${USER_UPLOAD}" == "true" ] || [ "${USER_UPLOAD}" == "1" ]; then
    echo -e "assuming user knows what they are doing have a good day."
    exit 0
fi

## add git ending if it's not on the address
if [[ ${GIT_ADDRESS} != *.git ]]; then
    GIT_ADDRESS=${GIT_ADDRESS}.git
fi

if [ -z "${USERNAME}" ] && [ -z "${ACCESS_TOKEN}" ]; then
    echo -e "using anon api call"
else
    GIT_ADDRESS="https://${USERNAME}:${ACCESS_TOKEN}@$(echo -e ${GIT_ADDRESS} | cut -d/ -f3-)"
fi

## pull git python repo
if [ "$(ls -A /mnt/server)" ]; then
    echo -e "/mnt/server directory is not empty."
    if [ -d .git ]; then
        echo -e ".git directory exists"
        if [ -f .git/config ]; then
            echo -e "loading info from git config"
            ORIGIN=$(git config --get remote.origin.url)
        else
            echo -e "files found with no git config"
            echo -e "closing out without touching things to not break anything"
            exit 10
        fi
    fi

    if [ "${ORIGIN}" == "${GIT_ADDRESS}" ]; then
        echo "pulling latest from github"
        git pull
    fi
else
    echo -e "/mnt/server is empty.\ncloning files into repo"
    if [ -z ${BRANCH} ]; then
        echo -e "cloning default branch"
        git clone ${GIT_ADDRESS} .
    else
        echo -e "cloning ${BRANCH}'"
        git clone --single-branch --branch ${BRANCH} ${GIT_ADDRESS} .
    fi

fi

export HOME=/mnt/server

echo "Installing python requirements into folder"
if [[ ! -z ${PY_PACKAGES} ]]; then
    pip install -U --prefix .local ${PY_PACKAGES}
fi

if [ -f /mnt/server/requirements.txt ]; then
    pip install -U --prefix .local -r ${REQUIREMENTS_FILE}
fi

echo -e "install complete"
exit 0