Skip to content
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

Docker image #936

Merged
merged 21 commits into from
Apr 30, 2024
Merged

Conversation

fathzer
Copy link
Contributor

@fathzer fathzer commented Apr 1, 2024

Type of pull request:

  • Bug fix
  • [ x] Feature
  • Other

Description:

Adds a workflow that creates a minimal, easy to use, Docker image.
It also contains some documentation about the image.

Related Issues:

This PR is related to #780 issue.

Checklist:

  • [ x] I have read and followed the contribution guidelines.
  • [ x] I have added necessary documentation (if applicable).
  • [ x] The changes pass all existing tests.

Screenshots/logs (if applicable):

Additional work required

In order to work, the workflow requires:

  • A Docker organization (let's say lichess-bot-devs) to be created in Docker Hub (I can help if required).
  • A DOCKER_ORGANIZATION action repository variable containing the name of the Docker Hub organization.
  • A DOCKER_IMG action repository variable containing the name of the Docker image (let's say lichess-bot).
  • Two action repository secrets DOCKER_USER and DOCKER_PWD containing, respectively, the login of the user that has rights to push to the docker hub organization and a token of this user with read, write and delete permissions (available in https://hub.docker.com/settings/security).

How it works?

Every push on master branch will trigger the build and publish of the image with the latest tag.
The workflow (Docker CI) can also be executed manually in the Github interface. In this case, it will ask for the tag to apply to the built image.

Probably this process can be improved.
Some pushes (typically changes in wiki folder) may not require an image update. But I was not sure to have a safe way to distinguish those minor updates.
I also added the manual trigger because I was wondering how I could reliably obtain a release version.

How can you see work before accepting the PR?

My fork built the fathzer/lichess-bot image available in Docker hub. Feel free to test it!

PS : Be careful, I'm a newbie in Github actions, and I don't known Python at all ... but I know a little Docker (I have been using it in a lot of professional or personal projects since 2014).

@AttackingOrDefending
Copy link
Member

I haven't used docker before and I have run into some problems while trying to test your docker. I have downloaded docker desktop and downloaded your image through it.
When I run docker run -d -v C:\Users\panti\Downloads:/engine --env OPTIONS=-v fathzer/lichess-bot I get a long hex string and then it quit. In the desktop app, the logs are:

Exception: The engine                              
2024-04-02 21:26:17                              ./engines/stockfish_24031109_x6                    
2024-04-02 21:26:17                              4_bmi2.exe file does not exist.

The structure is:

C:\USERS\PANTI\DOWNLOADS
│   config.yml
│   stockfish_24031109_x64_bmi2.exe
│
└───engines
        stockfish_24031109_x64_bmi2.exe

It is able to read the config.yml file but not Stockfish.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 2, 2024

Hi,

The first thing is as mentioned in 'wiki/How-to-use-the-Docker-image.md': be aware that this program will run inside the container ... in a Linux Alpine OS.
It seems you are trying to run an .exe ... on a linux OS. For sure it can't work.

Nevertheless, I tried to launch Stockfish inside this image and I didn't succeed. Looking at the Stockfish web site, there are a lot of Linux different versions. I tried with POPCNT and AVX2. Both do not work in the container (but run on the Ubuntu subsystem on my PC). Maybe there's something wrong between Stockfish and Alpine Linux (it's a very light Linux system, maybe something required by Stockfish is missing?).

I had a look at the Dockerfile of a Stockfish docker image based on Alpine. And it does not seem as simple as executing the compiled file contained in the package (they do a make).

I will investigate more tomorrow (now it's late in France ;-)).

@fathzer
Copy link
Contributor Author

fathzer commented Apr 3, 2024

Hi again,

The problem is that Stockfish requires the libgc library that is not included in Alpine Linux (see the answer of this StackOverflow question).

Here we have a well-known dilemma of Docker image producers; On the one hand, the image based on python:3-alpine is small (80MB), but does not have all the libraries that one would expect from a Linux distribution. On the other hand, an image based on python:3 is much more complete... but weighs 1GB... not to mention its share of vulnerabilities!

My proposal is to do as others do: Several variants.

I haven't pushed this into my PR yet (I will if it seems reasonable to you), but I put a new fathzer/lichess-bot:latest image based on python:3 on Docker hub (I ran Stockfish on it, without any problem), and the previous image based on python:3-alpine under the alpine tag.

@AttackingOrDefending
Copy link
Member

I downloaded SF for linux and the new image from docker hub but it still won't work because it doesn't find the executable, even though it finds config.yml. The folder contents are:

C:\USERS\PANTI\DOWNLOADS
│   config.yml
│   stockfish_24040206_x64_bmi2
│
└───engines
        stockfish_24040206_x64_bmi2

I'm still using Windows so I don't know if that is the problem, but I don't think it is since the error is

2024-04-04 21:42:59                              Exception: The engine                              
2024-04-04 21:42:59                              engines/stockfish_24040206_x64_                    
2024-04-04 21:42:59                              bmi2 file does not exist.

The command I am using: docker run -d -v C:\Users\panti\Downloads:/engine --env OPTIONS=-v fathzer/lichess-bot

My proposal is to do as others do: Several variants.
I haven't pushed this into my PR yet (I will if it seems reasonable to you),

If other engines can run on alpine (e.g. Leela, Berserk, Caissa, Seer), I think it is fine to have two versions.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 5, 2024

Hi,

I think the problem is in your config.yml file. If I understand well how lichess-bot works, it seems that lichess-bot searches for the executable in the lichess-bot relative path engines, but it is not there, you put in the absolute path /engine.

Here is the configuration I use:
Folder content:

C:\Users\jeanm\Desktop\lichess-docker-example
    config.yml
    stockfish
          stockfish_24040206_x64_bmi2
          ... (other files from the stockfish package)

config.yml:

engine:
  dir: "/engine/stockfish"
  name: "stockfish-ubuntu-x86-64-bmi2"
  working_dir: "/engine/stockfish"

And the command : docker run -d -v C:\Users\jeanm\Desktop\lichess-docker-example:/engine --env OPTIONS=-v fathzer/lichess-bot

If you want to inspect what is really in your container, you can launch a shell with the same configuration using: docker run -ti -v C:\Users\jeanm\Desktop\lichess-docker-example:/engine --env OPTIONS=-v fathzer/lichess-bot /bin/sh

If this does not fix the problem, please send the docker container's log (you can retrieve it in the containers tab of Docker desktop).

For the Alpine variant, I am pretty sure that most C engines may have some compatibility problem with it. But, fortunately, there's a lot of home made engines on Lichess for which Alpine will be a far better option. For instance ... mine ;-)
It is written in Java and using the fat standard image would only have disadvantages (size and vulnerabilities).

@fathzer
Copy link
Contributor Author

fathzer commented Apr 6, 2024

Hi,
I just pushed a commit that create 2 image flavors (a fat one, and the alpine one). I have also updated wiki/How-to-use-the-Docker-image.md.

@AttackingOrDefending
Copy link
Member

Thanks for the help in setting the docker up. It works now and can play a game.

Would it be possible to support homemade engines and extra game handlers? Is there any way that users can use custom homemade.py and extra_game_handlers.py without needing to build their own image? When I tried using a homemade engine I got:

2024-04-06 22:13:03                              AttributeError: module                             
2024-04-06 22:13:03                              'homemade' has no attribute                        
2024-04-06 22:13:03                              'CustomBot'

Also, can the logs in lichess_bot_auto_logs be written outside the docker? I see that docker desktop keeps the logs, so I'm not sure if we need this feature at the moment, but it could be a additional feature.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 7, 2024

Would it be possible to support homemade engines and extra game handlers? Is there any way that users can use custom homemade.py and extra_game_handlers.py without needing to build their own image?

Yes :-)
Docker allows you to mount your own files into the container's file system. The python files are located in /lichessbot (I have to add this information to documentation). So, mounting a file to /lichessbot/homemade.py or /lichessbot/extra_game_handlers.py works. Something like:
docker run -d -v C:\Users\me\lichess-docker-example:/engine -v C:\Users\me\lichess-docker-example\myhomemade.py:/lichessbot/homemade.py --env OPTIONS=-v fathzer/lichess-bot
Of course, if those files require some extra pip installation, it will not work.
But Docker is very versatile ;-) You can also change the launch command to make some pip install before launching lichess-bot.py. But making your own image seems a better solution to me.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 7, 2024

Also, can the logs in lichess_bot_auto_logs be written outside the docker? I see that docker desktop keeps the logs, so I'm not sure if we need this feature at the moment, but it could be a additional feature.

Ooops, I didn't noticed lichess-bot was writing logs in its file system! It's a (little) problem. Is there any way to deactivate this output?
Of course, as usual, the solution to write this logs outside the docker container is to mount a local folder to /lichessbot/lichess_bot_auto_logs (It's also a way to fix the little problem).

The problem is docker's file system is a copy on write system. So writing logs to it results in a lot of duplications and quickly ends with disk saturation. A Docker logging best practice is to log to the standard output stream, and configure the Docker logging system as you wish.

With the default configuration, the docker logs command allows you to get a container logs. To ease its use, I recommend to give a name to the container with the --name options of the docker run command.

Examples:

docker run -d -v C:\Users\me\lichess-docker-example:/engine -v C:\Users\me\lichess-docker-example\myhomemade.py:/lichessbot/homemade.py --env OPTIONS=-v --name myBot fathzer/lichess-bot
docker logs myBot

@AttackingOrDefending
Copy link
Member

By running python3 lichess-bot.py --disable_auto_logging the bot won't save the logs to lichess_bot_auto_logs.

Users can also save the games to a local folder by enabling the option in config.yml. If this is also a problem, then you can use the code here to warn users about it. It requires setting the environment variable LICHESS_BOT_DOCKER to work.

How to use homemade engines and extra_game_handlers should also be mentioned in How-to-use-the-Docker-image.md.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 7, 2024

By running python3 lichess-bot.py --disable_auto_logging the bot won't save the logs to lichess_bot_auto_logs.

Sorry, I should have seen this!
I propose that the Docker image always uses this option, as duplicating logs in a file sounds strange in the context of Docker (I will add this in documentation).

Users can also save the games to a local folder by enabling the option in config.yml. If this is also a problem, then you can use the code here to warn users about it. It requires setting the environment variable LICHESS_BOT_DOCKER to work.

I will add the LICHESS_BOT_DOCKER environment variable so that the Python process can detect that it is running in Docker.
Saving the games can be a must have for some users, and, if the user mounts a volume to save the games, he will have no problems (Unfortunately, I think there's no way from inside the container to check if a volume is mounted or not).
So, maybe, the warning message can be less dissuasive? I propose something like "Games will be saved to xxx, please ensure this is a mounted volume; Using the Docker's container internal file system will prevent you accessing the saved files and can lead to disk saturation."
Of course, I will add a word about that in How-to-use-the-Docker-image.md.

How to use homemade engines and extra_game_handlers should also be mentioned in How-to-use-the-Docker-image.md.

I will add this :-)

@AttackingOrDefending
Copy link
Member

AttackingOrDefending commented Apr 7, 2024

I propose that the Docker image always uses this option, as duplicating logs in a file sounds strange in the context of Docker (I will add this in documentation).

That's ok, but I think we should recommend users to use OPTIONS=-v to make debugging easier.

So, maybe, the warning message can be less dissuasive? I propose something like "Games will be saved to xxx, please ensure this is a mounted volume; Using the Docker's container internal file system will prevent you accessing the saved files and can lead to disk saturation."

This is a good warning.

Unfortunately, I think there's no way from inside the container to check if a volume is mounted or not

Could this help?

@fathzer
Copy link
Contributor Author

fathzer commented Apr 7, 2024

Unfortunately, I think there's no way from inside the container to check if a volume is mounted or not

Could this help?

Not really ;-). The exposed solution requires the user to remember to mount /var/run/docker.sock ... and to have Docker installed in the container. Adding an environment variable into the image seems much safer (It only fails if the user has intentionally overwritten the environment variable in its run command).

@fathzer
Copy link
Contributor Author

fathzer commented Apr 8, 2024

Hi,

Since yesterday, I've been wondering about the complexity of the Docker volume mounts needed to use a custom homemade.py or extra_game_handlers.py.
Currently, you have to make a mount for the config.yml, another for the homemade.py and yet another for the extra_game_handlers.py. It seems too complex to me.
I think that a solution requiring only the mount of a directory containing all these elements would be more elegant and simple to use.

The problem is homemade.py and extra_game_handlers.py have to be in the lichess-bot root directory and Docker doesn't allow selective mount that would only replace some files of the image by the ones in the docker host directory and preserve others. In other words, if the user mounts a directory with config.yml, homemade.py and extra_game_handlers.py at the location of lichess-bot.py, it will erase the whole content of this directory (lichess-bot.py, the libraries, etc...).

Here are the solutions I considered (in my order of preference ... But I must admit that my opinion is not very informed). All have in common a single volume mount to a path to be chosen (inside or outside of the lichess-bot root directory), let's say mount:

  1. Make engine_wrapper.py and model.py able to import homemade.py and extra_game_handlers.py directly from mount. Of course, to preserve compatibility, they would do that only when the program is launched under Docker (using an environment variable to check if lichess_bot is running under Docker). As I said, I know nothing about Python, but Google told me it can be done.
    I suppose we should also modify engine_wrapper.py and model.py to make them able to work from mount.
    Maybe I'm dreaming ;-)
  2. Have a pre-launch script that copies engine_wrapper.py, model.py, lichess-bot.py, lib, etc ... to a work subfolder of the mounted volume. That would slow down the container start a bit. Maybe one could have permission problems if the container does not work as root (running as root is a vulnerability) ... but works with the current structure and avoids writing in the container's file system (see next proposal).
  3. Have a pre-launch script that copies homemade.py and extra_game_handlers.py beside lichess-bot.py. This is not ideal because writing into the container's file system is always tricky (as explained in previous posts). Nevertheless, the pre-launch script could check if the copy is required before making it (typically, if the container is restarted and the files currently in the root directory have a modification date equal to the ones in mount, there's no need to make a copy).

Of course, we can stay on what is currently running!
Any comment or suggestion is welcome ;-)

@AttackingOrDefending
Copy link
Member

I too prefer option 1.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 10, 2024

I too prefer option 1.

Nice :-)
I found a very simple solution for homemade.py. I've just replaced, in the image, the provided homemade.py by a symbolic link to /engine/homemade.py. It works even if the file is missing in the mounted volume (for example if the user wants to run an uci engine).

I tried the same with extra_game_handlers.py, but, unfortunately, I got an error if the file is missing in the mounted volume. I will investigate a bit more ...

- Adds LICHESS_BOT_DOCKER environment variable to help Python program
detecting it is running in a Docker container
- Changes installation direction to /lichess-bot (instead of
/lichessbot)
- Changes the configuration folder path to /lichess-bot/cinfig instead
of /engine
- Adds a warning message if the docker container is configured to output
pgn files
- Makes lib/engine_wrapper.py and lib/model.py search for
lib.extra_game_handlers_failover if importing extra_game_handlers fails
- Prevent Python from writing to containers (set PYTHONDONTWRITEBYTECODE
to 1)
- Merges docker/Dockerfile and docker/Dockerfile-alpine
@fathzer
Copy link
Contributor Author

fathzer commented Apr 11, 2024

Hi,

I've updated the pull request with the following changes:

  • It implements the first option discussed earlier.
    • The docker image contains a copy of extra_game_handlers.py in lib\extra_game_handlers_failover.py (the copy is made while building the image to allow changing extra_game_handlers.py on your side with no need to duplicate changes anywhere).
    • lib/engine_wrapper.py and lib/model.py now search for lib.extra_game_handlers_failover if importing extra_game_handlers fails.
  • It adds LICHESS_BOT_DOCKER environment variable to help Python program detecting if it is running in a Docker container.
  • It changes installation direction to /lichess-bot (instead of /lichessbot), to make it consistent with the project name.
  • It changes the configuration folder path to /lichess-bot/config instead of /engine. This is more consistent with the Linux best naming practices for configuration folders. Warning: The command to run the image changes (the volume should be mounted to /lichess-bot/config instead of /engine.
  • It adds the warning message you proposed if the docker container is configured to output pgn files.
  • It prevents Python from writing to containers (set PYTHONDONTWRITEBYTECODE to 1).
  • It merges docker/Dockerfile and docker/Dockerfile-alpine to ease maintenance.
  • It updates the documentation.

Tell me if you want some more changes or if I made something wrong.

@AttackingOrDefending
Copy link
Member

In the wiki, instead of /home/me/myEngine:/engine it should be /home/me/myEngine:/lichess-bot/config, and instead of /home/me/myEngine/extra_game_handlers.py is should be /lichess-bot/extra_game_handlers.py. In general mentions of /engine and /lichessbot need updating.

I believe we should also mention that homemade.py is set up like extra_game_handlers.py.

I also think we should mention that in the config.yml all paths have to start with /lichess-bot and for dir and working_dir /lichess-bot/config/.

Lastly, I think we can look into publishing the images also in github packages (see here). It has a maximum stotage of 500MB, but maybe we can get under it with some zip or 7z compression.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 12, 2024

In the wiki, instead of /home/me/myEngine:/engine it should be /home/me/myEngine:/lichess-bot/config, and instead of /home/me/myEngine/extra_game_handlers.py is should be /lichess-bot/extra_game_handlers.py. In general mentions of /engine and /lichessbot need updating.

I believe we should also mention that homemade.py is set up like extra_game_handlers.py.

Sorry, I didn't update the wiki in the right branch of my project! Now it's fixed.

I also think we should mention that in the config.yml all paths have to start with /lichess-bot and for dir and working_dir /lichess-bot/config/.

Done

Lastly, I think we can look into publishing the images also in github packages (see here). It has a maximum stotage of 500MB, but maybe we can get under it with some zip or 7z compression.

I don't know Github package at all, and, to be honest, its interest for public packages is not obvious (Docker hub is the official repository that every Docker user know, like Maven central for Java packages).
Nevertheless, I will have a look at it (not sure to have time this week-end). I already saw it seems to be free and unlimited for publishing public packages :-)

@AttackingOrDefending
Copy link
Member

You can see the errors here. You should probably add a # type: ignore also to engine_wrapper.py. Can you test changing # type: ignore to # type: ignore[import-untyped]?

@fathzer
Copy link
Contributor Author

fathzer commented Apr 19, 2024

You can see the errors here. You should probably add a # type: ignore also to engine_wrapper.py.

done

Can you test changing # type: ignore to # type: ignore[import-untyped]?

It didn't work. I had to put # type: ignore[import-untyped,no-redef] to fix it (I hope it is not a problem).

@AttackingOrDefending
Copy link
Member

AttackingOrDefending commented Apr 20, 2024

# type: ignore[import-untyped,no-redef] is still better than # type: ignore. By changing the name to game_specific_options_docker as I did in my branch you can fix the no-redef errors, so you will only need to put # type: ignore[import-untyped].

@fathzer
Copy link
Contributor Author

fathzer commented Apr 20, 2024

I don't understand what is the problem with ignoring no-redef errors on lines concerned by what look like a myPi false positive to me.
Nevertheless, I tried your proposal here but, unfortunately, wasn't able to have Python build workflow work.

@AttackingOrDefending
Copy link
Member

AttackingOrDefending commented Apr 20, 2024

Removing line 101 should fix the issue with python-build.

I don't understand what is the problem with ignoring no-redef errors on lines concerned by what look like a myPi false positive to me.

We try to limit the amount of # type: ignore comments we use. We have used a similar approch here for the same reason.

When I tried using the homemade engines that come with lichess-bot (e.g. FirstMove) without providing a custom homemade.py file, I got an error:

2024-04-20 16:00:14                              ModuleNotFoundError: No module                     
2024-04-20 16:00:14                              named 'homemade'

@fathzer
Copy link
Contributor Author

fathzer commented Apr 20, 2024

Removing line 101 should fix the issue with python-build.

Yes 👍

I don't understand what is the problem with ignoring no-redef errors on lines concerned by what look like a myPi false positive to me.

We try to limit the amount of # type: ignore comments we use. We have used a similar approch here for the same reason.

Ok, so I've modified your proposal in model.py to remove the # type: ignore comment.
Probably something similar could be done in engine_wrapper.py ... by someone who knows Python (I think I've already written too much Python during this life ;-)). Then I would remove the copy of extra_game_handlers.py in lib/extra_game_handlers_failover.py.

When I tried using the homemade engines that come with lichess-bot (e.g. FirstMove) without providing a custom homemade.py file, I got an error:

2024-04-20 16:00:14                              ModuleNotFoundError: No module                     
2024-04-20 16:00:14                              named 'homemade'

If you don't provide any homemade.py in the volume mounted, the homemade.py link of the container is linked to nothing.
If you want homemade.py to have a failover, your Python code should be modified to look for this failover. On the other hand, I can simply add a warning about the fact that providing a homemade.py file is mandatory to use a home made engine.

@AttackingOrDefending
Copy link
Member

AttackingOrDefending commented Apr 21, 2024

Is there any flag that you can add to line 17, to only move the homemade.py file if it exists? If there isn't just add a warning and we can fix this in a later PR.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 21, 2024

Is there any flag that you can add to line 17, to only move the homemade.py file if it exists? If there isn't just add a warning and we can fix this in a later PR.

Unfortunately, the Dockerfile content (except the CMD line) is executed at build time and is written indelibly in the image.
I added the warning here.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 21, 2024

We try to limit the amount of # type: ignore comments we use. We have used a similar approch here for the same reason.

[...] something similar could be done in engine_wrapper.py by someone who knows Python (I think I've already written too much Python during this life ;-)). Then I would remove the copy of extra_game_handlers.py in lib/extra_game_handlers_failover.py.

I've just had an idea to do that easily, and to avoid polluting your code with try/except around imports of extra_game_handlers.py (the problem with homemade.py would reamain). I will check if it works today ...

@fathzer
Copy link
Contributor Author

fathzer commented Apr 21, 2024

I've just had an idea [...]

I've pushed the implementation of the following idea:
Handling extra_game_handlers fail over in many places in the code is (in my opinion) not a good practice.

Instead, I implemented a proxy for the extra_game_handler functions in lib/extra_game_handlers_wrapper (maybe lib/extra_game_handlers_proxy would be a better name, but wrapper looks familiar in your code).

This proxy contains the ugly try/except hacks and is used wherever extra_game_handlers is useful, with a standard clean import.

There's also no longer a copy of extra_game_handler in lib/extra_game_handlers_failover.py. Now, local and Docker hosted instances run the exact same code.

PS: The problem with missing homemade.py remains (at least until a future PR :-)).

@AttackingOrDefending
Copy link
Member

That was a nice change. Now we don't have to use # type: ignore comments.

@MarkZH We have to first create an account on Docker Hub and the Github container registry before we can merge this.

@MarkZH
Copy link
Collaborator

MarkZH commented Apr 25, 2024

Some suggestions from a complete Docker noob.

  1. The instructions need to mention that a Docker Hub account is required to download the container.
  2. The instructions should mention that only Linux images are available, so Linux executables are required.
  3. There should be instructions about how to stop the lichess-bot instance after starting, and how to restart it.

I have not been able to start the Docker version of lichess-bot since the container cannot find the config file. I created a folder with the following contents:

 Directory of C:\Users\Mark Harrison\Documents\GitHub\lichess-bot-docker

04/25/2024  12:43 AM    <DIR>          .
04/24/2024  11:47 PM    <DIR>          ..
04/25/2024  12:43 AM             5,640 config.yml
03/13/2024  04:08 AM           922,624 Genetic_Chess.exe
03/17/2024  07:02 PM             2,113 genome_example.txt

I know that my engine is a Windows engine, but the problems start earlier. When I run the Docker command

docker run -d -v Genetic_Chess.exe:/lichess-bot/config --name myBot fathzer/lichess-bot

A hex string is printed and the program immediately exits with this log:

2024-04-25 01:13:44 [04/25/24 08:13:44] INFO                                     lichess-bot.py:1051
2024-04-25 01:13:44                                  .   _/|                                        
2024-04-25 01:13:44                                  .  // o\                                       
2024-04-25 01:13:44                                  .  || ._)  lichess-bot                         
2024-04-25 01:13:44                              2024.3.21.1                                        
2024-04-25 01:13:44                                  .  //__\                                       
2024-04-25 01:13:44                                  .  )___(   Play on Lichess                     
2024-04-25 01:13:44                              with a bot                                         
2024-04-25 01:13:44                                                                                 
2024-04-25 01:13:44                     ERROR    Quitting lichess-bot due to an  lichess-bot.py:1119
2024-04-25 01:13:44                              error:                                             
2024-04-25 01:13:44                              Traceback (most recent call                        
2024-04-25 01:13:44                              last):                                             
2024-04-25 01:13:44                                File                                             
2024-04-25 01:13:44                              "/lichess-bot/lichess-bot.py",                     
2024-04-25 01:13:44                              line 1116, in <module>                             
2024-04-25 01:13:44                                  start_lichess_bot()                            
2024-04-25 01:13:44                                File                                             
2024-04-25 01:13:44                              "/lichess-bot/lichess-bot.py",                     
2024-04-25 01:13:44                              line 1053, in start_lichess_bot                    
2024-04-25 01:13:44                                  CONFIG =                                       
2024-04-25 01:13:44                              load_config(args.config or                         
2024-04-25 01:13:44                              "./config.yml")                                    
2024-04-25 01:13:44                                           ^^^^^^^^^^^^^^^^^^                    
2024-04-25 01:13:44                              ^^^^^^^^^^^^^^^^^^^^^^^^                           
2024-04-25 01:13:44                                File                                             
2024-04-25 01:13:44                              "/lichess-bot/lib/config.py",                      
2024-04-25 01:13:44                              line 381, in load_config                           
2024-04-25 01:13:44                                  with open(config_file) as                      
2024-04-25 01:13:44                              stream:                                            
2024-04-25 01:13:44                                       ^^^^^^^^^^^^^^^^^                         
2024-04-25 01:13:44                              FileNotFoundError: [Errno 2] No                    
2024-04-25 01:13:44                              such file or directory:                            
2024-04-25 01:13:44                              './config.yml'

@fathzer
Copy link
Contributor Author

fathzer commented Apr 25, 2024

Hi,

Some suggestions from a complete Docker noob.

  1. The instructions need to mention that a Docker Hub account is required to download the container.

There's no need of a Docker hub account to download (pull in Docker language) and run the image. You only need one if you want to publish (push in Docker language) an image.

  1. The instructions should mention that only Linux images are available, so Linux executables are required.

There's already the following sentence in the first line of the documentation : the UCI/XBoard program that runs your engine (be aware that this program will run inside the container ... in a Linux OS). I don't know what else to say.

  1. There should be instructions about how to stop the lichess-bot instance after starting, and how to restart it.

I added a chapter about stopping, based on the run example.

Nevertheless, usually, this information is not in the documentation of Docker images. In fact, how to stop a container does not depend on the image (it's a standard Docker instruction).
I understand it helps the Docker noob ;-), but the problem is that we can end up adding all the standard launch options (in the foreground/background, with inputs/outputs redirect, DNS settings ...etc), how to manage the logs, to inspect the container, to delete the container, to delete the image, etc ... In short, everything found in the (huge) Docker documentation.
At the opposite, the experienced Docker user expects documentation with the specifics of the image. You have what I think is a good example in the Postgres image documentation.

I have not been able to start the Docker version of lichess-bot since the container cannot find the config file. I created a folder with the following contents:

 Directory of C:\Users\Mark Harrison\Documents\GitHub\lichess-bot-docker

04/25/2024  12:43 AM    <DIR>          .
04/24/2024  11:47 PM    <DIR>          ..
04/25/2024  12:43 AM             5,640 config.yml
03/13/2024  04:08 AM           922,624 Genetic_Chess.exe
03/17/2024  07:02 PM             2,113 genome_example.txt

I know that my engine is a Windows engine, but the problems start earlier. When I run the Docker command

docker run -d -v Genetic_Chess.exe:/lichess-bot/config --name myBot fathzer/lichess-bot

[...]

There's a problem with the path of your configuration folder.
If your config file is in C:\Users\Mark Harrison\Documents\GitHub\lichess-bot-docker
You should try:

docker run -d -v C:\Users\Mark Harrison\Documents\GitHub\lichess-bot-docker:/lichess-bot/config --name myBot fathzer/lichess-bot

@AttackingOrDefending
Copy link
Member

AttackingOrDefending commented Apr 25, 2024

Can you change secrets.DOCKER_PWD to secrets.DOCKER_TOKEN and GB_REPO_PWD to GB_REPO_TOKEN?

@MarkZH
Copy link
Collaborator

MarkZH commented Apr 26, 2024

@fathzer Thanks. I got it working.

@fathzer
Copy link
Contributor Author

fathzer commented Apr 26, 2024

Can you change secrets.DOCKER_PWD to secrets.DOCKER_TOKEN and GB_REPO_PWD to GB_REPO_TOKEN?

done :-)

@AttackingOrDefending
Copy link
Member

@MarkZH Should I merge this?

@MarkZH
Copy link
Collaborator

MarkZH commented Apr 30, 2024

@MarkZH Should I merge this?

Go ahead.

@AttackingOrDefending AttackingOrDefending merged commit c629b59 into lichess-bot-devs:master Apr 30, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants