Skip to content

node.js generic

A generic node.js egg This will clone a git repo. It defaults to master if no branch is specified. Installs the node_modules on install. If you set user_upload then I assume you know what you are doing.

egg-node-js-generic.json

updated

Install

Installer image
node:20-trixie-slim
Install script
71 lines

Images

New servers use the first image. Users can change it on the Startup page.

  • Nodejs 25 default ghcr.io/ptero-eggs/yolks:nodejs_25
  • Nodejs 24 ghcr.io/ptero-eggs/yolks:nodejs_24
  • Nodejs 23 ghcr.io/ptero-eggs/yolks:nodejs_23
  • Nodejs 22 ghcr.io/ptero-eggs/yolks:nodejs_22
  • Nodejs 21 ghcr.io/ptero-eggs/yolks:nodejs_21
  • Nodejs 20 ghcr.io/ptero-eggs/yolks:nodejs_20
  • Nodejs 19 ghcr.io/ptero-eggs/yolks:nodejs_19
  • Nodejs 18 ghcr.io/ptero-eggs/yolks:nodejs_18
  • Nodejs 17 ghcr.io/ptero-eggs/yolks:nodejs_17
  • Nodejs 16 ghcr.io/ptero-eggs/yolks:nodejs_16
  • Nodejs 14 ghcr.io/ptero-eggs/yolks:nodejs_14
  • Nodejs 12 ghcr.io/ptero-eggs/yolks:nodejs_12

Startup

The Panel runs this command to start the server. It replaces each variable in the command with the value of that variable.

10 variables

Startup command

if [[ -d .git ]] && [[ 0 == "1" ]]; then git pull; fi; if [[ ! -z {{NODE_PACKAGES}} ]]; then /usr/local/bin/npm install {{NODE_PACKAGES}}; fi; if [[ ! -z {{UNNODE_PACKAGES}} ]]; then /usr/local/bin/npm uninstall {{UNNODE_PACKAGES}}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; if [[ "index.js" == "*.js" ]]; then /usr/local/bin/node "/home/container/index.js" {{NODE_ARGS}}; else /usr/local/bin/ts-node --esm "/home/container/index.js" {{NODE_ARGS}}; fi
  • GitHub Repo to clone I.E. https://github.com/parkervcp/repo_name

    GIT_ADDRESSUsers can edit

    nullable|string

  • The branch to install.

    BRANCHUsers can edit

    nullable|string

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

    USER_UPLOADUsers can edit

    required|boolean

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

    AUTO_UPDATEUsers can edit

    required|boolean

  • Install additional node packages. Use spaces to separate.

    NODE_PACKAGESUsers can edit

    nullable|string

  • Username to auth with git.

    USERNAMEUsers can edit

    nullable|string

  • 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

    ACCESS_TOKENUsers can edit

    nullable|string

  • Uninstall node packages. Use spaces to separate.

    UNNODE_PACKAGESUsers can edit

    nullable|string

  • The file that starts the app. Can be .js and .ts

    MAIN_FILEUsers can edit

    required|string|max:16

  • Any extra arguments for nodejs or ts-node

    NODE_ARGSUsers can edit

    nullable|string|max:64

Wings

Stop command
^C (SIGINT)
Running when the console shows
change this text 1
change this text 2

Readme

JavaScript Language Generic

This egg is designed to run any generic JavaScript application, allowing users to pull their own JavaScript 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"
  ]
}

Changes

  1. Update NodeJS egg

    · Daniel Barton · 7b958c8

  2. Bump timestamps

    · Daniel Barton · 5aecb35

  3. egg(nodejs): add Node.js 23 & 24 to image list

    · lajczi · d6f34ea

  4. NodeJS: Add Nodejs 22

    · Daniel Barton · c8ee814

  5. Fix docker image case

    · Daniel Barton · c6218f8

  6. Update repo names and remove some GH stuff for now

    · Daniel Barton · 8a5189b

All changes on GitHub

Problem with this egg?

Open an issue on GitHub. Include your Panel and Wings versions.

Install script 71 lines bash in node:20-trixie-slim Show
#!/bin/bash
# NodeJS App Installation Script
#
# Server Files: /mnt/server
apt update
apt install -y git curl jq file unzip make gcc g++ python3 python3-dev python3-pip libtool

echo -e "updating npm. please wait..."
npm install npm@latest --location=global

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 js 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

echo "Installing nodejs packages"
if [[ ! -z ${NODE_PACKAGES} ]]; then
    /usr/local/bin/npm install ${NODE_PACKAGES}
fi

if [ -f /mnt/server/package.json ]; then
    /usr/local/bin/npm install --production
fi

echo -e "install complete"
exit 0