Skip to content

Commit

Permalink
Added a nixos development build for for local linux development (#105)
Browse files Browse the repository at this point in the history
- Updated `dream2nix` to the latest version.
- Removed deprecated inputs related to `dream2nix`, including `devshell`, `flake-compat`, `flake-parts`, and others.
- Added new inputs for `purescript-overlay` and `pyproject-nix`.
- Updated `nixpkgs` and `flake-utils` to the latest versions.

This update syncs the project dependencies with the latest available versions, potentially improving stability and compatibility.

* flake building for develop now works

* add composer and php to flake.nix

* added preinstall to flake.nix and more packages

* Added temp buildsteps file

File Is to be renamed and moved before merge with main.
This file contains a modified version of vagrant/provision.sh
specifically made for the nixos development process

* moved from mariadb to mysql

Mariadb kept crashing my computer and causing long hangs in the terminal, so I swapped to mysql for development

* stopped cp of .env.example to .env and fixed access list for mysql

Mysql was granting all writes on "*" to both users, mysql uses "%" as a wildcard, I forgot and messed up

* updated shell.nix to only run composer update when running

* fixed broken minecraft forge egg

* before I break vagrant I took back the old configuration file as well

* Transitioned most systemd tasks to nixos task configurations and replaced /var/www/pterodactyl to cwd

* updated flake.lock with latest nix configuration

* everything up to starting wings is working, time to see if I can get web server working as well

* added "--rm \" to buildsteps

* fixed many issues and working on getting mariadb working properly

* fix: mariadb now gets initialized properly

* fix: update favicon & password reset (#91)

* removed linux info for local development

* chore: moved buildsteps to nix folder

* removed all unnecesary services in configuration.nix

* added docker-compose.yml so that the buildsteps file has something to do

* Switching to using mysql in a docker container over inside the nix flake

* Fix: Changed from nixos-unstable to nixos-24.05 packages

Also added mariadb service back in flake.nix and stop mariadb docker container on nix shutdown

* updated flake.lock to match packager version change

* fix: buildsteps script not connecting to mariadb server

* fix: wings didn't work in cli so made it a docker container and organized docker-compose files

* As we include a Dockerfile now, we need to push .dockerignore for smaller images

* fix: changed directory for wings docker container from ./nix/pterodacytl/<name> to ./<name>

* fix: changed docker-compose paths in flake.nix

* fix: wings docker-compose.yml now uses network_mode host

* added some resets for mariadb and pterodactyl whenever the app is started(subject to change in the future

* updated some nixos specific "Features" and ensure mariadb and wings folders exists

* deleted mariadb reset in buildsteps and added 20 seconds for mariadb to start

deleting the mariadb folders was causing errors to occur, and not waiting long enough causes database connection errors

* added mariadb docker-compose file and added extra stuff to .gitignore

* added nix files to dockerignore

* added linux development guide

* Disable recaptcha on setup

* docs: Formatting fixes

* docs: Linux doesn't use vagrant anymore

* docs: https does not work

I really need to proofread my docs before I push them

* docs: Added Prereqs for linux local development

* docs: we do not need to be told about the docker image twice

* deleted configuration.nix and decreased flake.nix clutter

* docs(README): notes about local development on linux

added info about pterodactyl wings not working in nixos dev environment

* fixed some broken markdown formatting

* Revert last commit

* added one more VERY important step to readme

* added a few fixes with systems other than mine

* added a run.sh file to easily run nixos

* Added a env.nix file because it's configuration is slightly different to normal env

* fix(README): use Git for cloning

* Updated pterodactyl discord links to pyrodactyl links

* added a health check to maria to ensure it's up before continuing

* removed benign sql query and added --no-interaction to key:generate

* updated more pterodactyl links to pyrodactyl links

---------

Co-authored-by: he3als <[email protected]>
  • Loading branch information
olwalkey and he3als authored Oct 5, 2024
1 parent e9c1ed6 commit 330735e
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 620 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Vagrantfile
vagrant/
.swc/
.turbo/
nix/
flake.nix
flake.lock

50 changes: 50 additions & 0 deletions .env.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:70nPUP+VYp/0HXxmnXbM2BJO6E1+JizA1XhAf72bAG8=
APP_THEME=pterodactyl
APP_TIMEZONE=UTC
APP_URL="http://localhost:8000"
APP_LOCALE=en
APP_ENVIRONMENT_ONLY=false

# If you are using a proxy server set this to be
# the Proxy server's ip adddress.
# TRUSTED_PROXIES=*

LOG_CHANNEL=daily
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=panel
DB_USERNAME=pyrodactyluser
DB_PASSWORD=pyrodactyl

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis

HASHIDS_SALT=qFr7NZGVVpsX79HvKPqv
HASHIDS_LENGTH=8

MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="Pterodactyl Panel"
# You should set this to your domain to prevent it defaulting to 'localhost', causing
# mail servers such as Gmail to reject your mail.
#
# @see: https://github.com/pterodactyl/panel/pull/3110
# MAIL_EHLO_DOMAIN=panel.example.com

APP_SERVICE_AUTHOR="[email protected]"
18 changes: 9 additions & 9 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ body:
- type: markdown
attributes:
value: |
Bug reports should only be used for reporting issues with how the software works. For assistance installing this software, as well as debugging issues with dependencies, please use our [Discord server](https://discord.gg/pterodactyl).
Bug reports should only be used for reporting issues with how the software works. For assistance installing this software, as well as debugging issues with dependencies, please use our [Discord server](https://pyro.host/discord).
- type: textarea
- type: textarea
attributes:
label: Current Behavior
description: Please provide a clear & concise description of the issue.
validations:
required: true

- type: textarea
- type: textarea
attributes:
label: Expected Behavior
description: Please describe what you expected to happen.
validations:
required: true

- type: textarea
- type: textarea
attributes:
label: Steps to Reproduce
description: Please be as detailed as possible when providing steps to reproduce, failure to provide steps will result in this issue being closed.
Expand All @@ -45,14 +45,14 @@ body:
placeholder: 1.4.2
validations:
required: true

- type: input
id: egg-details
attributes:
label: Games and/or Eggs Affected
description: Please include the specific game(s) or egg(s) you are running into this bug with.
placeholder: Minecraft (Paper), Minecraft (Forge)

- type: input
id: docker-image
attributes:
Expand All @@ -66,18 +66,18 @@ body:
label: Error Logs
description: |
Run the following command to collect logs on your system.
Wings: `sudo wings diagnostics`
Panel: `tail -n 150 /var/www/pterodactyl/storage/logs/laravel-$(date +%F).log | nc pteropaste.com 99`
placeholder: "https://pteropaste.com/a1h6z"
render: bash
validations:
required: false

- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](https://github.com/pterodactyl/panel/issues) to see if an issue already exists for your problem.
description: Please [search here](https://github.com/pyrohost/pyrodactyl/issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues before opening this issue.
required: true
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Installation Help
url: https://discord.gg/pterodactyl
url: https://pyro.host/discord
about: Please visit our Discord for help with your installation.
- name: General Question
url: https://discord.gg/pterodactyl
about: Please visit our Discord for general questions about Pterodactyl.
url: https://pyro.host/discord
about: Please visit our Discord for general questions about Pyrodactyl.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body:
- type: checkboxes
attributes:
label: Is there an existing feature request for this?
description: Please [search here](https://github.com/pterodactyl/panel/issues?q=is%3Aissue) to see if someone else has already suggested this.
description: Please [search here](https://github.com/pyrohost/pyrodactyl/issues?q=is%3Aissue) to see if someone else has already suggested this.
options:
- label: I have searched the existing issues before opening this feature request.
required: true
Expand Down
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ _ide_helper_models.php
public/assets/manifest.json

# For local development with docker
# Remove if we ever put the Dockerfile in the repo
.dockerignore
docker-compose.yml
#docker-compose.yml

# for image related files
misc
Expand All @@ -33,8 +31,15 @@ resources/lang/locales.js
/public/build
/public/hot
result
docker-compose.yaml
#docker-compose.yaml
.swc/
.turbo
# Sentry Config File
.env.sentry-build-plugin

# Nix specific stuff
nix/docker/wings/pterodactyl
nix/docker/maria/mariadata
nix/docker/wings/etc/
nix/docker/wings/lib/
nix/docker/maria/mariadb_data/
90 changes: 31 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,23 @@ Pyrodactyl is the Pterodactyl-based game server management panel that focuses on

## Running Pyrodactyl

> [!TIP]
> Pyrodactyl now [has a Docker image avaliable](https://github.com/pyrohost/pyrodactyl/pkgs/container/pyrodactyl), which for previous users of the Pterodactyl panel in Docker, should make it easy to migrate.
>
> If you want to setup Pyrodactyl in Docker from scratch, see the [`docker-compose.example.yml`](https://github.com/pyrohost/pyrodactyl/blob/main/docker-compose.example.yml).
> [!WARNING]
> Nothing is Perfect, that apply's to this panel.
> If you are migrating your data from pterodactyl, always make sure you take a backup of your pterodactyl database and other relevant data.
### Prerequisites

- Latest LTS version of NodeJS
- Git

### Linux

> [!TIP]
> Pyrodactyl now [has a Docker image avaliable](https://github.com/pyrohost/pyrodactyl/pkgs/container/pyrodactyl), which for previous users of the Pterodactyl panel in Docker, should make it easy to migrate.
>
> If you want to setup Pyrodactyl in Docker from scratch, see the [`docker-compose.example.yml`](https://github.com/pyrohost/pyrodactyl/blob/main/docker-compose.example.yml). You can follow [Pterodactyl's instructions](https://github.com/pterodactyl/panel/tree/1.0-develop/.github/docker#pterodactyl-panel---docker-image) on setting it up.
<details><summary>Running on Linux</summary>
<p>

Setting up Pyrodactyl is a breeze on Linux. Follow the [official Pterodactyl documentation](https://pterodactyl.io/panel/1.0/getting_started.html) for your distribution up to the **Download Files** step.

Expand All @@ -60,8 +66,7 @@ mkdir -p /var/www/pterodactyl
cd /var/www/pterodactyl

# Download and extract panel
curl -Lo main.tar.gz https://github.com/pyrohost/pyrodactyl/archive/refs/heads/main.tar.gz
tar -xzf main.tar.gz --strip-components=1 -C /var/www/pterodactyl pyrodactyl-main/
git clone https://github.com/pyrohost/pyrodactyl.git /var/www/pterodactyl --depth=2

# Permissions for caches
chmod -R 755 storage/* bootstrap/cache/
Expand All @@ -71,6 +76,7 @@ npm ci && npm run ship
```

Proceed with the rest of the installation as you would with the official panel.
</p></details>

### Windows

Expand Down Expand Up @@ -102,74 +108,40 @@ Pyrodactyl is the world's first Pterodactyl panel that can be developed and run

- We do not recommend using Hyper-V as your virtualization layer. If your Vagrant installation asks you for a password, this is because you used Hyper-V. The password will be your Windows password.
- We recommend using VMWare Workstation or VirtualBox instead.

</p>
</details>
</p></details>

<details><summary>On Linux</summary>
<p>

### Extra prerequsites

In addition to the previous prerequsites, you need:

- [Vagrant](https://www.vagrantup.com/)
- `libvirtd`
- `nfs-utils`

### Install nfs-utils

- **Fedora:** `sudo dnf install nfs-utils`

- **Ubuntu/Debian:** `sudo apt-get install nfs-kernel-server`
### Prerequisites

Afterwards, start it:
- Nix
- Docker

- `sudo systemctl start nfs-server`
- To have it start when your computer starts
- `sudo systemctl enable nfs-server`
Local Development on Linux is A little different, because vagrant is the buggy software that it is, I couldn't get it to run properly... Anywhere, and on no Distro.
So I decided that instead of using Vagrant, I would use nix. This turned out to be a very good idea. Now, using nix the development boots faster because we aren't using
an entire vm to host a development server, it also uses way less resources, and is much easier to configure exactly how you want through the nix/buildsteps.sh file.

### Notes about Local Development on Linux
### How to get started

Using [Vagrant](https://www.vagrantup.com) on Linux is incredibly simple. Verify you met the prerequsites above, then follow these simple steps:
To get started, you obviously need nix on your system, and you need to configure nix to support flake files. Depending on your OS, this can vary

1. Clone the Pyrodactyl panel repository
2. Run `npm i` to install all required packages
3. Run `npm run ship` to build Pyrodactyl. This will cache the results of the build and upload sourcemaps to Sentry. Subsequent builds without code changes will finish in milliseconds.
1. run `npm i` to install all the packages necessary.
1. Run `npm run ship` to build Pyrodactyl. This will cache the results of the build and upload sourcemaps to Sentry. Subsequent builds without code changes will finish in milliseconds.
1. Copy `.env.nix` to `.env`
1. Run `nix develop`. This will setup wings and the necessary services in order to run Pyrodactyl's databases, services, and app. This process could take up to 15 minutes.
1. Once you receive a message that says "Pyrodactyl is now up and running at localhost:8000", visit that URL in your browser and login with the default credentials provided in your console. **It's important that you use localhost to connect to Pyrodactyl! If you use 127.0.0.1, you will run into CORS issues and other issues that will not be fixed.**
1. Visit http://localhost:8000/admin to provision your first server on Pyrodactyl!

> [!IMPORTANT]
> In order for `vagrant up` to work, your files must be in the `/var/www/pterodactyl` directory unless manually changed in the `Vagrantfile`!

4. Run `vagrant up`. This will setup wings and the necessary services in order to run Pyrodactyl's databases, services, and app. This process could take up to 15 minutes.
5. Once you receive a message that says "Pyrodactyl is now up and running at localhost:3000", visit that URL in your browser and login with the default credentials provided in your console. **It's important that you use localhost to connect to Pyrodactyl! If you use 127.0.0.1, you will run into CORS issues and other issues that will not be fixed.**

### Notes about Local Development on Linux

- If your having trouble installing Virtualbox on linux, you can try to follow instructions in these [docs](https://github.com/pyrohost/pyrodactyl/blob/main/VirtualBoxSetup.md)

- It should be stated that when running on Linux, if you are using a virtual machine manager other than libvirtd, you will have to add your configuration to the [Vagrantfile](https://github.com/pyrohost/pyrodactyl/blob/main/Vagrantfile). If not, it will boot the VM with 512 mb of ram, which is not enough to build Pyrodactyl!

- There might be a weird bug the first time you run `vagrant up`, where you get an error like this:
Due to a slight bug or two, pterodactyl wings does not as present work properly using the nixos development environment\
This will hopefully be fixed later, but for now just be warned

```
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o vers=3,udp xxx.xxx.xxx.x:/home/user/pyrodactyl /var/www/pterodactyl
Stdout from the command:
Stderr from the command:
mount.nfs: Connection refused
```

If this happens, just re-run `vagrant up` and it should work.

- If you're having permission errors, try running using sudo, e.g `sudo vagrant up`

</p>
</details>
</p></details>

## Star History

Expand Down
Loading

0 comments on commit 330735e

Please sign in to comment.