Skip to content

Commit

Permalink
Make image easier to use in non root mode + Cleanup (#958)
Browse files Browse the repository at this point in the history
The main change is to make the config.yml link during the build.
The advantages are:

- No more annoying ln: /lichess-bot/config.yml: File exists message in log when a container is restarted.
- More importantly: for those, like me, who don't need custom extra_game_handlers.py or extra_game_handlers.py, this allows again (as in version 2024.5.1.2) to run a container based on this image as a non-root user without digging into the source code to guess what permissions are required to prevent the launch from failing with a permission error. Since the link is created during construction, no permissions are needed to use it at runtime. PS: Running a container as root on a production environment is a well-known worst practice. Copying extra_game_handlers.py or extra_game_handlers.py into the container file system still requires guessed permissions.

Easier in non root mode:
- Makes config.yml link in image, not at runtime.
Cleanup
- Removes useless ARG in Docker file.
- Removes useless files in image
  • Loading branch information
fathzer authored May 19, 2024
1 parent 908e0f0 commit d7ff497
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ COPY . .

RUN python3 -m pip install --no-cache-dir -r requirements.txt

ARG CONF_FOLDER=$LICHESS_DIR/config

RUN chmod +x docker/copy_files.sh
RUN chmod +x docker/copy_files.sh && ln -s $LICHESS_DIR/config/config.yml config.yml

CMD docker/copy_files.sh && python3 lichess-bot.py ${OPTIONS} --disable_auto_logging
2 changes: 2 additions & 0 deletions docker/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docker/*
!docker/copy_files.sh
docs/
wiki/
.git*
Expand Down
2 changes: 0 additions & 2 deletions docker/copy_files.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

ln -s /lichess-bot/config/config.yml /lichess-bot/

if [ -e /lichess-bot/config/homemade.py ]; then
ln -sf /lichess-bot/config/homemade.py /lichess-bot/
fi
Expand Down

0 comments on commit d7ff497

Please sign in to comment.