Skip to content

Feat/composer #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ RUN apt-get update && apt-get install -y \
php${PHP_VERSION}-maxminddb \
php${PHP_VERSION}-protobuf \
php${PHP_VERSION}-opcache \
php${PHP_VERSION}-dev \
&& wget -q -O /tmp/composer.phar https://getcomposer.org/download/latest-stable/composer.phar \
&& SHA256=$(wget -q -O - https://getcomposer.org/download/latest-stable/composer.phar.sha256) \
&& echo "$SHA256 /tmp/composer.phar" | sha256sum -c - \
&& mv /tmp/composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer \
&& rm -rf /var/lib/apt/lists/*

# Create user and set environment variables
Expand All @@ -100,4 +106,4 @@ STOPSIGNAL SIGINT
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

CMD ["/entrypoint.sh"]
CMD ["/entrypoint.sh"]
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,49 @@ With **Cloudflared**, you can create a secure tunnel to your server, making it a

✅ You have successfully set up Cloudflared and connected it to your server!<br><br>
🔹 Info: Your web server ip and port does not have to be accessible from outside and can have a local IP such as 127.0.0.1.
<br><br>
## How to Use Composer Modules

This Pterodactyl Egg allows you to easily install additional PHP libraries (Composer modules) for your server. Here's how:

1. **Locate the `Composer modules` Variable:** When creating or editing your server in the Pterodactyl panel, you will find a variable named `Composer modules`.

2. **Specify the Modules:** In the value field of the `Composer modules` variable, enter a space-separated list of the Composer packages you wish to install. You can also specify the desired version constraints.

* **Basic Package:** To install the latest stable version of a package, simply enter its name:
```
vendor/package
```
Example: `symfony/http-foundation`

* **Specific Version:** To install a specific version or version range, use the following format:
```
vendor/package:version_constraint
```
Examples:
* `monolog/monolog:^2.0` (installs the latest version within the 2.x branch)
* `doctrine/orm:~2.10` (installs a version compatible with 2.10)
* `nesbot/carbon:^2.50`

* **Multiple Modules:** To install multiple modules, separate them with spaces:
```
vendor/package1:version vendor/package2 vendor/package3:^1.0
```
Example: `symfony/http-foundation ^6.0 monolog/monolog guzzlehttp/guzzle`

3. **Save and Start/Restart Your Server:** After entering the desired Composer modules in the `COMPOSER_MODULES` variable, save your server configuration. If your server is already running, you will need to restart it for the changes to take effect.

4. **Module Installation:** During the server startup process, the Egg will automatically detect the modules listed in the `COMPOSER_MODULES` variable and attempt to install them using Composer. You can monitor the server console for the installation output.

**Important Notes:**

* Ensure that the package names and version constraints you enter are correct and exist on Packagist ([https://packagist.org/](https://packagist.org/)).
* Incorrectly specified modules or version constraints may lead to installation errors. Check your server console for any error messages.
* Installing a large number of modules or very complex dependencies can increase the server startup time.
* This Egg assumes that Composer is already installed within the server environment.

By following these steps, you can easily extend the functionality of your server by adding various PHP libraries through Composer modules.

<br><br>
## FAQ

Expand Down
48 changes: 29 additions & 19 deletions egg-nginx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": "PTDL_v2",
"update_url": null
},
"exported_at": "2025-02-03T10:01:15+01:00",
"exported_at": "2025-04-03T22:34:54+02:00",
"name": "Pterodactyl Nginx Egg",
"author": "[email protected]",
"description": "Pterodactyl Nginx Egg\r\n\r\nThe Pterodactyl Nginx Egg is a web server solution for Pterodactyl, featuring Nginx, PHP, Git support, Cloudflare Tunnel integration, and optional WordPress installation. It supports AMD64 & ARM64 architectures and allows users to choose their preferred PHP version (8.0 \u2013 8.4).\r\nKey Features:\r\n\r\n\u2705 Supports multiple PHP versions\r\n\u2705 Git integration for automatic deployment\r\n\u2705 Cloudflare Tunnel support for secure remote access\r\n\u2705 Optional WordPress setup\r\n\u2705 HTTPS configuration support\r\n\u2705 Automatic updates for Git repositories",
"description": "Pterodactyl Nginx Egg\r\n\r\nThe Pterodactyl Nginx Egg is a web server solution for Pterodactyl, featuring Nginx, PHP, Git support, Cloudflare Tunnel integration, composer and optional WordPress installation. It supports AMD64 & ARM64 architectures and allows users to choose their preferred PHP version (8.0 \u2013 8.4).\r\nKey Features:\r\n\r\n\u2705 Supports multiple PHP versions\r\n\u2705 Git integration for automatic deployment\r\n\u2705 Cloudflare Tunnel support for secure remote access\r\n\u2705 Optional WordPress setup\r\n\u2705 HTTPS configuration support\r\n\u2705 Automatic updates for Git repositories",
"features": null,
"docker_images": {
"ghcr.io\/ym0t\/pterodactyl-nginx-egg:8.4-latest": "ghcr.io\/ym0t\/pterodactyl-nginx-egg:8.4-latest",
Expand All @@ -17,7 +17,7 @@
"ghcr.io\/ym0t\/pterodactyl-nginx-egg:8.0-latest": "ghcr.io\/ym0t\/pterodactyl-nginx-egg:8.0-latest"
},
"file_denylist": [],
"startup": "echo \"{{PHP_VERSION}}\" > \"php_version.txt\";\r\n\r\nif [ \"{{GIT_UPDATE}}\" = \"1\" ]; then \r\n {{STARTUP_COMMAND_GIT}}; \r\nfi;\r\n\r\nif [ \"{{CLOUDFLARED_STATUS}}\" = \"1\" ]; then \r\n echo \"{{CLOUDFLARED_TOKEN}}\" > \"cloudflared_token.txt\";\r\n {{STARTUP_COMMAND_CLOUDFLARED}};\r\nfi;\r\n\r\n{{STARTUP_COMMAND}};",
"startup": "echo \"{{PHP_VERSION}}\" > \"php_version.txt\";\r\n\r\nif [ \"{{GIT_UPDATE}}\" = \"1\" ]; then \r\n {{STARTUP_COMMAND_GIT}}; \r\nfi;\r\n\r\nif [ \"{{CLOUDFLARED_STATUS}}\" = \"1\" ]; then \r\n echo \"{{CLOUDFLARED_TOKEN}}\" > \"cloudflared_token.txt\";\r\n {{STARTUP_COMMAND_CLOUDFLARED}};\r\nfi;\r\n\r\nif [[ -n \"{{COMPOSER_MODULES}}\" ]]; then\r\n composer require {{COMPOSER_MODULES}} --working-dir=\/home\/container\/www --no-interaction --ansi;\r\nfi;\r\n\r\n{{STARTUP_COMMAND}};",
"config": {
"files": "{\r\n \"nginx\/conf.d\/default.conf\": {\r\n \"parser\": \"file\",\r\n \"find\": {\r\n \" listen\": \"listen {{server.build.default.port}};\"\r\n }\r\n },\r\n \"php\/php.ini\": {\r\n \"parser\": \"file\",\r\n \"find\": {\r\n \"memory_limit =\": \"memory_limit = {{env.memory_limit}};\"\r\n }\r\n }\r\n}",
"startup": "{\r\n \"done\": \"Services successfully launched\"\r\n}",
Expand All @@ -33,13 +33,13 @@
},
"variables": [
{
"name": "PHP Version",
"description": "Select the correct PHP version! See the tag behind the Docker image. \r\nExample: Selected image (ghcr.io\/ym0t\/nginx_php:8.4)\r\nEnter in the field: 8.4",
"env_variable": "PHP_VERSION",
"default_value": "",
"name": "Startup Command",
"description": "The startup file for Nginx.",
"env_variable": "STARTUP_COMMAND",
"default_value": ".\/nginx.sh",
"user_viewable": true,
"user_editable": true,
"rules": "required|string|max:3",
"rules": "required|string",
"field_type": "text"
},
{
Expand All @@ -53,23 +53,23 @@
"field_type": "text"
},
{
"name": "Memory_limit",
"description": "Change the memory_limit value from the php.ini file",
"env_variable": "memory_limit",
"default_value": "128M",
"name": "PHP Version",
"description": "Select the correct PHP version! See the tag behind the Docker image. \r\nExample: Selected image (ghcr.io\/ym0t\/nginx_php:8.4)\r\nEnter in the field: 8.4",
"env_variable": "PHP_VERSION",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "required|string|max:20",
"rules": "required|string|max:3",
"field_type": "text"
},
{
"name": "Startup Command",
"description": "The startup file for Nginx.",
"env_variable": "STARTUP_COMMAND",
"default_value": ".\/nginx.sh",
"name": "Memory_limit",
"description": "Change the memory_limit value from the php.ini file",
"env_variable": "MEMORY_LIMIT",
"default_value": "128M",
"user_viewable": true,
"user_editable": true,
"rules": "required|string",
"rules": "required|string|max:20",
"field_type": "text"
},
{
Expand Down Expand Up @@ -161,6 +161,16 @@
"user_editable": true,
"rules": "required|string",
"field_type": "text"
},
{
"name": "Composer modules",
"description": "Enter a space-separated list of Composer packages with their version constraints to be installed. For example: vendor\/package1:^2.0 vendor\/package2:~1.5",
"env_variable": "COMPOSER_MODULES",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string",
"field_type": "text"
}
]
}
}