norimicry / stardew-multiplayer-docker

Run a Stardew Valley Multiplayer Server with docker-compose
94 stars 23 forks source link

add steam build option #21

Closed pinduzera closed 6 months ago

pinduzera commented 6 months ago

This creates an alternative docker-compose.yaml and Dockerfile that downloads and runs the game from Steam servers through steamcmd.

Probably we could make it a little bit simpler/better but works as intended, also handles Steam Guard if the user has it.

dlach524 commented 6 months ago

Does this work for Windows? When I try to build based off the latest git and after creating the files you covered in this pull, I get this error:

F:\Games\Modding Stuff\Stardew\stardew-multiplayer-docker-local\stardew-multiplayer-docker>docker compose build --no-cac
he
time="2024-04-29T22:47:45-04:00" level=warning msg="F:\\Games\\Modding Stuff\\Stardew\\stardew-multiplayer-docker-local\\stardew-multiplayer-docker\\docker-compose.yml: `version` is obsolete"
[+] Building 0.0s (0/0)  docker:default
2024/04/29 22:47:45 http2: server: error reading preface from client //./pipe/docker_engine: file has already been close[+] Building 59.7s (11/16)                                                                               docker:default
 => [valley internal] load build definition from Dockerfile                                                        0.0s
 => => transferring dockerfile: 1.56kB                                                                             0.0s
 => [valley internal] load metadata for docker.io/jlesage/baseimage-gui:debian-11                                  0.6s
 => [valley internal] load .dockerignore                                                                           0.1s
 => => transferring context: 2B                                                                                    0.0s
 => CACHED [valley  1/12] FROM docker.io/jlesage/baseimage-gui:debian-11@sha256:dbf3ef5bab5680c5b51f2352e5a637971  0.0s
 => [valley internal] load build context                                                                           0.1s
 => => transferring context: 527.70kB                                                                              0.0s
 => [valley  2/12] RUN apt-get update && apt-get install -y wget unzip tar strace mono-complete xterm gettext-ba  53.1s
 => [valley  3/12] RUN wget -qO dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/d4b71fac-a2  4.9s
 => [valley  4/12] RUN wget --user-agent="Mozilla" https://mirror.cloudcraft.info/SMAPI_latest.tar.gz -qO /data/n  0.3s
 => [valley  5/12] COPY [mods/, /data/Stardew/game/Mods/]                                                          0.1s
 => [valley  6/12] COPY scripts/ /opt/                                                                             0.1s
 => ERROR [valley  7/12] RUN chmod +x /data/Stardew/game/StardewValley &&     chmod -R 777 /data/Stardew/ &&       0.4s
------
 > [valley  7/12] RUN chmod +x /data/Stardew/game/StardewValley &&     chmod -R 777 /data/Stardew/ &&     chown -R 1000:1000 /data/Stardew &&     chmod +x /opt/*.sh:
0.333 chmod: cannot access '/data/Stardew/game/StardewValley': No such file or directory
------
failed to solve: process "/bin/sh -c chmod +x /data/Stardew/game/StardewValley &&     chmod -R 777 /data/Stardew/ &&     chown -R 1000:1000 /data/Stardew &&     chmod +x /opt/*.sh" did not complete successfully: exit code: 1

That's when doing a "docker compose build --no-cache"

pinduzera commented 6 months ago

I have not tried on Windows, but shouldnt matter. I could try though.

Nonetheless, by your log doesn't seem to be using the right dockerfile. I ditched the /game/ from the game path, and it is complaining about not find a file on that directory that I have removed because the downloaded file from steam doesn't have that extra folder like the GOG version.

pinduzera commented 6 months ago

Just built under windows here (This is a Linux Container, so WSL is required). It is a different Dockerfile as the one in the main repository so, you should build pointing to it using the -f argument, if you just clone the repository and:

docker-compose -f docker-compose-steam.yml build

dlach524 commented 6 months ago

Just built under windows here (This is a Linux Container, so WSL is required). It is a different Dockerfile as the one in the main repository so, you should build pointing to it using the -f argument, if you just clone the repository and:

docker-compose -f docker-compose-steam.yml build

Thanks, that got me further and I was able to build with that command. Upon bringing it up with "docker-compose -f docker-compose-steam.yml up" the server is not accessible and I get the black screen in VNC. It looks like something is still trying to find it in the "game" path:

stardew  | sed: can't read /data/Stardew/game/Stardew Valley: No such file or directory

And it looks like I have a problem with the start.sh file (which I had placed in docker/)

stardew  | bash: line 1: /data/Stardew/start.sh: No such file or directory

I tried rebuilding it with --no-cache and bringing it back up, but I still get the same result. Not sure what I'm doing wrong... still pretty new to Docker though so I might be screwing something up.

pinduzera commented 6 months ago

@dlach524 ignore my last Comment, during the cleanup I forgot to add the COPY statement to the Dockerfile-steam. Replace that file with the new one and you should be good to go.

dlach524 commented 6 months ago

@dlach524 ignore my last Comment, during the cleanup I forgot to add the COPY statement to the Dockerfile-steam. Replace that file with the new one and you should be good to go.

Ah, good to know! I've blocked myself out of my Steam Guard after too many failed attempts to so I'll have to try to rebuild later. In the meantime, I'm wondering, should this:

COPY docker-entrypoint.sh /startapp.sh

Be this instead?

COPY docker-entrypoint-steam.sh /startapp.sh
pinduzera commented 6 months ago

Be this instead?

COPY docker-entrypoint-steam.sh /startapp.sh

You are right, fixed. Some of these isssues happened because initially I planned to a have a single file that would handle Steam and GOG. Probably Possible, but would be a much bigger file with a bunch of conditionals. Keeping them separated looked like a little bit more sane.

dlach524 commented 6 months ago

Alright, just rebuilt with no-cache, build went OK, but something doesn't quite seem right when composing up:

stardew  | cat: /data/Stardew/game/Mods/AutoLoadGame/config.json: No such file or directory

I updated the docker-compose-steam.yml file to remove "game" from the path, but that didn't seem to make a difference here.

stardew  | s6-applyuidgid: fatal: unable to exec /startapp.sh: No such file or directory

This seems to be copied without issue during the build...

stardew  | [s6-finish] sending all processes the TERM signal.
stardew  | [s6-finish] sending all processes the KILL signal and exiting.
stardew exited with code 111

And it actually shuts down at the end. Not sure what's going on here... going to try starting all over again.

Edit: Did a fresh git clone, created the files again, re-built with --no-cache, composed up with the yml, and getting the same errors. Wondering if I need to purge something at the Docker desktop level. Or maybe there's some kind of conflict with the original Dockerfile / docker-entrypoint / docker-compose files.

pinduzera commented 6 months ago

Humm, have just resync to make sure I was running the exact same project. It is working no issues. Any additional log?

Try cloning from my repo instead of the original one just for testing. and use ONLY the following commands:

cd stardew-multiplayer-docker ... EXPORT STUFF

docker-compose -f docker-compose-steam.yml build --no-cache

docker-compose -f docker-compose-steam.yml up -d

pinduzera commented 6 months ago

@dlach524 after some additinal testing the Stardew was actually working but there were some script that was doing cat /data/Stardew/game/Mods/AutoLoadGame/config.json and was not finding the file and was spamming the Docker log.

Since I couldn't trace it, I've added the /game/ again.

About the sigkill, I think it should have been something on your side.

dlach524 commented 6 months ago

Finally, success! I cloned your repository, rebuilt, and launched without issue. Something must be different with whatever nomicry has in his repo... I ran Beyond Compare to check the Dockerfile, docker-compose, docker-entrypoint files and didn't see any differences, so whatever the difference is seems to lie outside of those. Thanks for all your help and patience!

In any case, if anyone reading this has the same issue, here's what you want to run to clone the repo:

git clone https://github.com/pinduzera/stardew-multiplayer-docker.git

Make sure you follow the instructions to set your STEAM_USER, STEAM_PASS, and STEAM_GUARD (if you have 2FA) before attempting to build. Then:

docker-compose -f docker-compose-steam.yml build --no-cache

Followed by:

docker-compose -f docker-compose-steam.yml up -d

Good luck!

pinduzera commented 6 months ago

I expect it to be merged in here though. I rather not scatter the project's effort. Let @norimicry take a look whenever he can :)

Now it is battle tested at least.

norimicry commented 6 months ago

Thanks for the work @pinduzera! Life has been busy. A majority of users use Steam so this will be great.

norimicry commented 6 months ago

@pinduzera I think you're right that two different files would be the best approach, one for Steam, one for GOG. Having it all in one with variables, conditionals, etc would just introduce too much complexity and room for error. Working on converting the initial file to a GOG variant since you've already added the Steam files. Great work again.