Skip to content

Commit

Permalink
mobile dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Nov 15, 2023
1 parent 17b7626 commit e8d87f7
Show file tree
Hide file tree
Showing 5 changed files with 101 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
```
10 changes: 10 additions & 0 deletions command/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -41,6 +42,7 @@ enum Repository {
LilaWs,
LilaDbSeed,
Lifat,
Mobile,
LilaFishnet,
LilaEngine,
LilaSearch,
Expand Down Expand Up @@ -141,6 +143,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 @@ -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
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
12 changes: 12 additions & 0 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down Expand Up @@ -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
;;
Expand Down

0 comments on commit e8d87f7

Please sign in to comment.