Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LILA_WS_REPOSITORY_DIR=../lila-ws
LILA_REPOSITORY_DIR=../lila
94 changes: 33 additions & 61 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,39 @@
FROM ubuntu:bionic-20191202
ARG OPENJDK_TAG=14.0.2-jdk-buster
FROM openjdk:${OPENJDK_TAG}

ARG SBT_VERSION=1.3.13

RUN if [ -z "$(command -v yum)" ] ; \
then \
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion; \
else \
curl https://bintray.com/sbt/rpm/rpm | tee /etc/yum.repos.d/bintray-sbt-rpm.repo && \
yum update && \
yum install -y sbt-$SBT_VERSION && \
sbt sbtVersion; \
fi

ARG YARN_VERSION=1.22.4

RUN apt-get update && apt-get install -y gnupg2 && \
apt-get install -y apt-transport-https ca-certificates && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn=${YARN_VERSION}-1 && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
yarn global add gulp

SHELL ["/bin/bash", "-c"]

RUN useradd -ms /bin/bash lichess \
&& apt-get update \
&& apt update \
&& apt-get install sudo \
# Disable sudo login for the new lichess user.
&& echo "lichess ALL = NOPASSWD : ALL" >> /etc/sudoers

ENV TZ=Etc/GMT
RUN sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && sudo echo $TZ > /etc/timezone

# Run as a non-privileged user.
USER lichess

ADD build /home/lichess/build

#node
RUN export HOME=/home/lichess \
&& sudo /home/lichess/build/node-init.sh

#yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \
&& sudo apt-key add /home/lichess/build/signatures/yarn.asc \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

#mongodb
RUN sudo apt-key add /home/lichess/build/signatures/mongodb-org.asc \
&& echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

RUN sudo apt-get update && sudo apt update \
&& sudo apt-get install -y \
unzip \
zip \
nodejs \
mongodb-org \
parallel \
&& sudo apt install -y \
yarn \
redis-server \
git-all

#Java
RUN /home/lichess/build/sdkman-init.sh \
&& source "$HOME/.sdkman/bin/sdkman-init.sh" \
&& sdk install java 13.0.2.hs-adpt && sdk install sbt

RUN sudo yarn global add gulp-cli \
# Silence the parallel citation warning.
&& sudo mkdir -p ~/.parallel && sudo touch ~/.parallel/will-cite \
# Make directories for mongodb
&& sudo mkdir -p /data/db && sudo chmod 666 /data/db \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean \
&& sudo rm -rf /home/lichess/build

ADD run.sh /home/lichess/run.sh

# Use UTF-8 encoding.
ENV LANG "en_US.UTF-8"
ENV LC_CTYPE "en_US.UTF-8"
ENV TZ=Etc/GMT

WORKDIR /home/lichess

ENTRYPOINT ./run.sh
ADD run.sh .
59 changes: 26 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,24 @@
# lichocker - [lichess.org](https://lichess.org) run in a [Docker](https://www.docker.com/) container
# lichocker - [lichess.org](https://lichess.org) run as a [Docker](https://www.docker.com/) container stack

## Prerequisites

* [Install Git](https://git-scm.com/downloads).
* [Install Docker](https://docs.docker.com/install/).
* [Install Docker Compose](https://docs.docker.com/compose/install/).
* *Recommended*: Increase your Docker runtime memory to 4GB and your CPUs to 4 ([Mac](https://docs.docker.com/docker-for-mac/#advanced), [Windows](https://docs.docker.com/docker-for-windows/#advanced), and configure the `docker-machine` assigned memory and CPUs for VirtualBox).
* Check out lichocker (`git clone https://github.com/BrandonE/lichocker`) and open the directory in your terminal: `cd /YOUR/PATH/TO/lichocker`
* Check out [lila](https://github.com/ornicar/lila), the main project behind Lichess: `git clone --recursive https://github.com/ornicar/lila.git`
* Check out [lila-ws](https://github.com/ornicar/lila-ws), which manages Websockets. `git clone https://github.com/ornicar/lila-ws.git`
* Add the following line to your `/etc/hosts` file: `127.0.0.1 lichess-assets.local`

## Obtaining the Docker image

To obtain the image you can build it yourself or retrieve it from docker hub

### Building the image

Run the following while in the lichocker directory: `docker build --tag brandone211/lichess .`

### Retrieving from Docker Hub

```
docker login
docker pull brandone211/lichess
```

The Docker Hub repository can be found [here](https://hub.docker.com/r/brandone211/lichess/).

## Running

* Run lila in a Docker container using the image obtained above, replacing the path to your local lila repository in the following command:
* lila and lila-ws source codes must be available to the containers. Hence, you must export their location in the `.env` file. By default, they reference the parent directory.

* To start the stack with `mongodb`, `redis`, `lila-ws` and `lila`, simply call `docker-compose`:

```
docker run \
--mount type=bind,source=/YOUR/ABSOLUTE/PATH/TO/lila,target=/home/lichess/projects/lila \
--mount type=bind,source=/YOUR/ABSOLUTE/PATH/TO/lila-ws,target=/home/lichess/projects/lila-ws \
--publish 9663:9663 \
--publish 9664:9664 \
--name lichess \
--interactive \
--tty \
brandone211/lichess
docker-compose up
```

* Wait until you see the following message:
Expand All @@ -59,6 +37,24 @@ docker run \

You can run fishnet (in another Docker container if desired) by following [these instructions](https://github.com/niklasf/fishnet).

## Viewing the logs

To view the logs, you can use docker or docker-compose. Here is how you can easily do so with docker-compose:

1. Open a new terminal
2. Navigate to lichocker
3. Run the command to view the logs
```
docker-compose logs <NAME_OF_THE_SERVICE>
```
example:
```
docker-compose logs lila
```
Add `-f` after logs for tailing (`docker-compose logs -f lila`).

> **_NOTE:_** If you don't want to run multiple terminals open at once, instead of running docker-compose in foreground, do so in background by adding the `-d` option: `docker-compose up -d`

## Rebuilding Lichess

Because your lila directory exists on your host machine and is mounted onto the container, you can modify the code and rebuild on the host machine and it will take effect on the container. Run `/YOUR/ABSOLUTE/PATH/TO/lila/ui/build` to update the client side modules. Auto-reloading is enabled for the server side Scala code via sbt.
Expand All @@ -67,8 +63,5 @@ For more information, including the guide used to create lichocker, please see t

## Other Commands

* Exiting the Docker container: Ctrl+C
* Stopping the Docker container: `docker stop lichess`
* Restarting the Docker container: `docker start lichess --attach --interactive`
* View the output of the running Docker container that you previously exited: `docker attach lichess`
* Remove the Docker container to mount a different volume: `docker rm lichess`
* Exiting Docker Compose in the foreground: `CTRL+C`
* Exiting Docker Compose in the background: `docker-compose down`
Loading