pterodactyl / panel

Pterodactyl® is a free, open-source game server management panel built with PHP, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
https://pterodactyl.io
Other
6.7k stars 1.7k forks source link

Host shared folders on servers #552

Closed F0x06 closed 4 years ago

F0x06 commented 7 years ago

Hi, I have 8 Garry's Mod servers, and I'm thinking to switch to Pterodactyl to manage my servers, this panel is amazing! Excellent work!. But I need one last thing, shared folders, typically in Garry's Mod you can mount other source games content with the file garrysmod/cfg/mount.cfg

"mountcfg"
{
        "cstrike"       "/home/container/SHARED_SRCDS_CONTENT/cstrike"
        "tf"            "/home/container/SHARED_SRCDS_CONTENT/tf"
... etc

For all contents i have a 27G folder, which solution i have to allow server's docker's to access that folder without copying it every time ?

Thank you !

F0x06 commented 7 years ago

@Derkades I don't want to copy 27G every time, 216G for 8 servers is not good, I want to mount the 27G contents folder in servers dockers. So they can access it to allow Garry's Mod to use it.

F0x06 commented 7 years ago

As a temporary solution I edited the server creation function in Pterodactyl/Daemon to add the read-only host shared folder /srv/daemon-shared

diff --git a/src/controllers/docker.js b/src/controllers/docker.js
index ce35e14..742a15f 100644
--- a/src/controllers/docker.js
+++ b/src/controllers/docker.js
@@ -369,12 +369,18 @@ class Docker {
                             Destination: Config.get('docker.timezone_path'),
                             RW: false,
                         },
+                        {
+                            Source: "/srv/daemon-shared",
+                            Destination: "/shared",
+                            RW: false,
+                        },
                     ],
                     Env: environment,
                     ExposedPorts: exposed,
                     HostConfig: {
                         Binds: [
                             Util.format('%s:/home/container', this.server.path()),
+                            Util.format('%s:/shared', "/srv/daemon-shared"),
                             Util.format('%s:%s:ro', Config.get('docker.timezone_path'), Config.get('docker.timezone_path')),
                         ],
                         Tmpfs: {

So, now on my Garry's Mod servers i can use

"mountcfg"
{
        "cstrike"       "/shared/source_contents/cstrike"
...
}

It would be awesome if we can have a setting on the server creation page to add custom mounts,

for example, a list with \<host path> \<server path> \<read-only 1|0>

In my case:

DaneEveritt commented 7 years ago

We have this on the radar for the next daemon release. 👍🏼

F0x06 commented 7 years ago

@DaneEveritt Awesome thank you ! :)

I'm verry happy to see a game panel so powerful, beautiful, and free ! i will support you on patreon, and after migration of my game servers, i will also publish my service/packs

DaneEveritt commented 7 years ago

Reopening this because I don't believe we have another issue tracking this feature currently.

F0x06 commented 7 years ago

@DaneEveritt Oh sorry.

Malachiel87 commented 6 years ago

this is will be implemented on 0.7.x?

sgtaziz commented 6 years ago

@DaneEveritt ^ would love to use this feature, only thing holding me back from upgrading to 0.7.x since I've modified my 0.6.x setup to allow it. I would be more than happy to help with the development if you need some PRs sent over

danfeldmann commented 6 years ago

push one of the most missed features which prevent us to replace our current panel with pterodactyl :/

Malachiel87 commented 6 years ago

+1 shared folder is one of limitation using dockers and it prevent me to use some tools

DaneEveritt commented 6 years ago

I am aware that you want this, commenting the same +1 on it every week does not make it happen any quicker.

rouing commented 6 years ago

It would be nice to see docker volume support for this.

F0x06 commented 5 years ago

Any update on this :) ?

Blamo27 commented 5 years ago

@F0x06 Yes could be great

xaviergmail commented 5 years ago

If anyone is still looking to achieve this until we get an official solution, the following has worked for me (Syntax has changed a bit since F0x06's answer)

{
    Target: "/shared",
    Source: "/srv/daemon-shared",
    Type: 'bind',
    ReadOnly: true,
},

Also, #714 is related

Forge-Media commented 5 years ago

I'm thinking of implementing @xaviergmail suggestion to try solve duplicate source game data for multiple instances of CSGO, if each server can access a shared mount which contains the files. I've only got 50GB of storage on my VPS.

  1. If the mount is read-only what happens when CSGO (or another source game) starts and checks for updates? It can't write to the mount, would this not cause problems?
  2. Simply change the mount to allow writing or have a CRON script on the host to update the game in the shared mount?
  3. Would there be any advantage to using a Docker Volume over a simple folder on the host?
xaviergmail commented 5 years ago

My suggestion mainly pertains to Garry's Mod where it pulls in content from other source games (e.g mounting CS:S, CS:GO, Ep1, Ep2, TF2, ZPS, Portal 1 + Portal 2, the list goes on and on) using cfg/mount.cfg Where this uses up easily 50GB+ per install.

For your use case I'd instead recommend just using a folder on the host (which the host itself would update) and editing the csgo egg to remove the auto updater on restart.

parkervcp commented 5 years ago

I'm thinking of implementing @xaviergmail suggestion to try solve duplicate source game data for multiple instances of CSGO, if each server can access a shared mount which contains the files. I've only got 50GB of storage on my VPS.

  1. If the mount is read-only what happens when CSGO (or another source game) starts and checks for updates? It can't write to the mount, would this not cause problems?

This would cause updates to error out.

  1. Simply change the mount to allow writing or have a CRON script on the host to update the game in the shared mount?

If every server is trying to adjust files at the same time it will most likely cause lots of issues.

  1. Would there be any advantage to using a Docker Volume over a simple folder on the host?

No advantage of a volume over the bind mount that we already do. Volumes are also in the /var/lib/docker folder which can cause issues of its own.

Forge-Media commented 5 years ago

@xaviergmail thanks, I've created a custom CSGO egg for this. Though I would still need to mount the host (CSGO) folder for the containers to access it, correct?

@parkervcp I will keep the mount read-only for safety and shedule updates on the host. I have successfully run multiple instances of CSGO with separate start scripts, server.cfg and ports, though I was using an alternative Linux game manager to do this, so it should technically be possible, I hope with Pterodactyl.

I should have asked, when a server is currently created using Pterodactyl, the HOME variable is set to /home/container. This allows the start script to simply reference ./srcds_run.

parkervcp commented 5 years ago

That is again more of a #714 then. As I completely understand what you were looking for.

kgns commented 5 years ago

@Forge-Media for CS:GO, you can create a master server using ptero, then create a symbolic link at /srv/shared/csgo folder pointing to the master server folder (i.e. /srv/daemon-data/xxx-xxx-xxx-xx-xx/csgo) with ln -s command. Then use the above configuration to load /srv/shared/csgo folder as a bind mount. And lastly on your install script (or somewhere else), overwrite all the bulky .vpk files with symbolic links pointing to the actual data stored in /srv/shared/csgo/ mount (ln -sf command). This will save you 16-18 GB per server. You can apply a similar logic for maps if you wanted to. It is tedious to maintain, but better than having to waste 20gb per server.

Since the .vpk files will be symbolic links that are writable in the docker container, when the game auto updates, it will delete the symbolic link (just the link), and download the new version of that vpk file which should be 100 MB each. You can then have a cron job to reapply the symbolic links (deleting updated vpk files, instead linking them again to the master server's updated vpk files).

igortomiatti commented 4 years ago

I tried to do it this way, but the container is unable to access symbolic link outside his scope.

@kgns How did you make it work?

I created a base server at /home/steamcmd/base_csgo and made symbolic links pointing to all files in the server folder created by pterodactyl in /srv/daemon-data/"server id"

Then I changed the owner of the files to the pterodactyl user and group.

kgns commented 4 years ago

mount your base installation folder using things discussed above, like: https://github.com/pterodactyl/panel/issues/552#issuecomment-522169995

if you set your target the same as your source, then your symlink will function both on the host machine and in the container

igortomiatti commented 4 years ago

@kgns Now it worked, I had forgotten that step.

Thank you!

sebackend commented 4 years ago

If anyone is still looking to achieve this until we get an official solution, the following has worked for me (Syntax has changed a bit since F0x06's answer)

{
    Target: "/shared",
    Source: "/srv/daemon-shared",
    Type: 'bind',
    ReadOnly: true,
},

Also, #714 is related

Where does this configuration go? I need to share the base installation from csgo across all my servers

dodoflix commented 1 year ago

If anyone is still looking to achieve this until we get an official solution, the following has worked for me (Syntax has changed a bit since F0x06's answer)

{
    Target: "/shared",
    Source: "/srv/daemon-shared",
    Type: 'bind',
    ReadOnly: true,
},

Also, #714 is related

Where does this configuration go? I need to share the base installation from csgo across all my servers

Did you find where this config goes? Or anybody knows where to put this config piece?

zag1024 commented 1 year ago

If anyone is still looking to achieve this until we get an official solution, the following has worked for me (Syntax has changed a bit since F0x06's answer)

{
    Target: "/shared",
    Source: "/srv/daemon-shared",
    Type: 'bind',
    ReadOnly: true,
},

Also, #714 is related

Where does this configuration go? I need to share the base installation from csgo across all my servers

Did you find where this config goes? Or anybody knows where to put this config piece?

This is no longer necessary, as mounts are built into the current versions of Wings and the panel. You can find the instructions for configuring this feature here: https://pterodactyl.io/guides/mounts.html