diff --git a/README.md b/README.md index 0e805bd6..0914e273 100644 --- a/README.md +++ b/README.md @@ -233,3 +233,56 @@ docker compose run --rm ui bash -c "cd /pgn-viewer && pnpm run sass-dev && pnpm ``` See the changes on the PGN Viewer demo page: http://localhost:8091/ + +### Mobile + +#### On your host machine: + +1. Install the Android SDK +2. Connect your Android phone via USB +3. Make sure your phone is in developer mode and USB debugging is enabled +4. Configure lila to run with your host's hostname instead of localhost + ```bash + ./lila-docker hostname + ``` +5. Ensure phone is on wifi and can access lila using that hostname + ``` + http://hostname-here:8080 # instead of http://localhost:8080 + ``` +6. Run: + ```bash + adb tcpip 5555 + ``` +7. You should see the phone in the devices list: + ```bash + adb devices + ``` + +#### On the container: + +1. Get a shell on the container: + + ```bash + docker compose exec -it mobile bash + ``` + +2. Connect to your phone: + + ```bash + # get the ip address from your phone's wifi settings + adb connect 192.168.1.xxx + # you should see the phone in the devices list + adb devices + ``` + +3. Install the app dependencies: + + ```bash + flutter pub get + dart run build_runner build + ``` + +4. Run the app: + ```bash + flutter run --dart-define=LICHESS_HOST=http://hostname-here:8080 --dart-define=LICHESS_WS_HOST=http://hostname-here:8080 + ``` diff --git a/command/src/main.rs b/command/src/main.rs index fc7750a9..b9900830 100644 --- a/command/src/main.rs +++ b/command/src/main.rs @@ -23,6 +23,7 @@ struct OptionalService { #[derive(Debug, Clone, PartialEq, EnumString, strum::Display, Eq, EnumIter)] #[strum(serialize_all = "kebab-case")] enum ComposeProfile { + Mobile, StockfishPlay, StockfishAnalysis, ExternalEngine, @@ -41,6 +42,7 @@ enum Repository { LilaWs, LilaDbSeed, Lifat, + Mobile, LilaFishnet, LilaEngine, LilaSearch, @@ -141,6 +143,14 @@ fn prompt_for_optional_services() -> Result, Error> { "Select which optional services to include:\n (Use arrows, to toggle, to continue)\n", ) .required(false) + .item( + OptionalService { + compose_profile: Some(ComposeProfile::Mobile), + repositories: vec![Repository::Mobile].into(), + }, + "Mobile app", + "Flutter-based mobile app", + ) .item( OptionalService { compose_profile: Some(ComposeProfile::StockfishPlay), diff --git a/docker-compose.yml b/docker-compose.yml index a2d86d70..f19f1a32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,6 +55,18 @@ services: - lila - lila_ws + mobile: + build: + context: docker + dockerfile: mobile.Dockerfile + tty: true + networks: + - lila-network + volumes: + - ./repos/mobile:/app + profiles: + - mobile + api_docs: build: context: docker diff --git a/docker/mobile.Dockerfile b/docker/mobile.Dockerfile new file mode 100644 index 00000000..d72d6765 --- /dev/null +++ b/docker/mobile.Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/cirruslabs/flutter:3.13.9 + +RUN apt-get update +RUN apt install -y \ + clang \ + cmake \ + iputils-ping \ + libgtk-3-dev \ + ninja-build \ + pkg-config + +RUN dart --disable-analytics + +WORKDIR /app diff --git a/lila-docker b/lila-docker index 1004c262..d675285f 100755 --- a/lila-docker +++ b/lila-docker @@ -49,6 +49,13 @@ run_setup_config() { cp conf/lila.original.conf conf/lila.conf cp conf/lila-ws.original.conf conf/lila-ws.conf + if [ ! -z "$1" ]; then + echo "Setting hostname to $1..." + sed -i "s/localhost/$1/g" conf/lila.conf + sed -i "s/localhost/$1/g" conf/lila-ws.conf + docker compose restart lila lila_ws + fi + # if we're running on Gitpod, we need to replace the localhost URLs with the Gitpod URLs if [ ! -z "$GITPOD_WORKSPACE_ID" ]; then echo "Replacing localhost URLs with Gitpod URLs..." @@ -159,6 +166,11 @@ case $1 in format) run_formatter ;; + hostname) + HOSTNAME=$(hostname) + read -p "Enter hostname [${HOSTNAME}]: " VALUE + run_setup_config ${VALUE:-$HOSTNAME} + ;; gitpod-welcome) run_gitpod_welcome ;;