Skip to content

Commit

Permalink
mobile dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Nov 24, 2023
1 parent 20bf71c commit add9374
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
11 changes: 11 additions & 0 deletions command/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct OptionalService {
#[derive(Debug, Clone, PartialEq, EnumString, strum::Display, Eq, EnumIter)]
#[strum(serialize_all = "kebab-case")]
enum ComposeProfile {
Mobile,
StockfishPlay,
StockfishAnalysis,
ExternalEngine,
Expand All @@ -65,6 +66,8 @@ enum Repository {
LilaDbSeed,
#[strum(serialize = "lichess-org/lifat")]
Lifat,
#[strum(serialize = "lichess-org/mobile")]
Mobile,
#[strum(serialize = "lichess-org/lila-fishnet")]
LilaFishnet,
#[strum(serialize = "lichess-org/lila-engine")]
Expand Down Expand Up @@ -213,6 +216,14 @@ fn prompt_for_optional_services() -> Result<Vec<OptionalService>, Error> {
"Select which optional services to include:\n (Use arrows, <space> to toggle, <enter> 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),
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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
Expand Down
14 changes: 14 additions & 0 deletions docker/mobile.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ case $1 in
format)
run_formatter
;;
hostname)
HOSTNAME=$(hostname)
read -p "Enter hostname [${HOSTNAME}]: " VALUE
;;
*)
show_help
exit 1
Expand Down

0 comments on commit add9374

Please sign in to comment.