Skip to content

Commit a34720e

Browse files
committed
Update DOCKER.md
1 parent 0fa4034 commit a34720e

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed

DOCKER.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Docker: Dev/Build Environment for Betaflight Configurator (Tauri)
2+
3+
This document explains how to build and run a containerized environment for web, desktop (Tauri), and Android builds using the `DockerFile` in this folder.
4+
5+
Note: The Dockerfile has not been fully validated end-to-end yet. Treat this as a starting point; please report gaps and update after the first successful build.
6+
7+
## Prerequisites: Install Docker
8+
9+
- Linux (Ubuntu/Debian):
10+
- Follow the official guide: https://docs.docker.com/engine/install/
11+
- After install, add your user to the docker group so you can run without sudo, then re-login:
12+
- `sudo usermod -aG docker "$USER" && newgrp docker`
13+
- macOS:
14+
- Install Docker Desktop: https://docs.docker.com/desktop/setup/mac/
15+
- Windows 10/11:
16+
- Install Docker Desktop (WSL 2 backend strongly recommended): https://docs.docker.com/desktop/setup/windows/
17+
18+
Verify installation:
19+
20+
```bash
21+
docker --version
22+
docker info
23+
```
24+
25+
## What’s in the image
26+
27+
Base: Debian 12 (bookworm-slim)
28+
29+
The Dockerfile installs:
30+
31+
- Toolchains
32+
- Rust (stable via rustup) + Android Rust targets: aarch64, armv7, i686, x86_64
33+
- OpenJDK 17 (for Android builds)
34+
- Node.js 22 (via NodeSource) + Yarn 1.x (1.22.22)
35+
- System deps for Tauri (GTK/WebKit etc.): `libwebkit2gtk-4.1-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev`
36+
- Build essentials: `clang llvm g++-multilib build-essential git` and more
37+
- Android SDK components
38+
- Command line tools (latest)
39+
- Platform tools
40+
- Android platform 34
41+
- Build tools 34.0.0
42+
- NDK 26.3.11579204
43+
- Environment
44+
- ANDROID_SDK_ROOT=/usr/local/android-sdk
45+
- NDK_HOME=/usr/local/android-sdk/ndk/26.3.11579204
46+
- PATH includes Android cmdline-tools, Cargo, etc.
47+
- Non-root user
48+
- `developer` user, working directory `/app`, entrypoint `/bin/bash`
49+
50+
## Build the image
51+
52+
Run from the repository root so the Docker context includes all needed files:
53+
54+
```bash
55+
docker build -t bf-configurator:dev -f tauri/betaflight-configurator/DockerFile .
56+
```
57+
58+
Optional: cache SDK and toolchains across runs using named volumes (recommended):
59+
60+
```bash
61+
docker volume create android-sdk
62+
63+
docker build -t bf-configurator:dev -f tauri/betaflight-configurator/DockerFile .
64+
```
65+
66+
## Start a dev shell in the container
67+
68+
Mount the repo and (optionally) caches. This drops you into `/app` as the `developer` user.
69+
70+
```bash
71+
docker run --rm -it \
72+
-v "$PWD":/app \
73+
-v android-sdk:/usr/local/android-sdk \
74+
bf-configurator:dev
75+
```
76+
77+
If you plan to build repeatedly, you can also persist Rust and Cargo caches:
78+
79+
```bash
80+
docker volume create rustup-cache
81+
82+
docker volume create cargo-cache
83+
84+
docker run --rm -it \
85+
-v "$PWD":/app \
86+
-v android-sdk:/usr/local/android-sdk \
87+
-v rustup-cache:/usr/local/rustup \
88+
-v cargo-cache:/usr/local/cargo \
89+
bf-configurator:dev
90+
```
91+
92+
## Project layout in the container
93+
94+
- Repo is mounted at `/app`
95+
- Project folder for Tauri: `/app/tauri/betaflight-configurator`
96+
97+
Change into it before running yarn/tauri commands:
98+
99+
```bash
100+
cd /app/tauri/betaflight-configurator
101+
```
102+
103+
## Web build (Vite)
104+
105+
```bash
106+
yarn install
107+
# Development server (not exposed unless you map ports)
108+
yarn dev
109+
# Production build
110+
yarn build
111+
```
112+
113+
To access the dev server from host, run the container with port mapping, e.g. `-p 5173:5173`, and include `--host 0.0.0.0` when starting the dev server.
114+
115+
## Desktop (Tauri) build
116+
117+
```bash
118+
yarn install
119+
# Build the web assets first
120+
yarn build
121+
# Build the Tauri app (Linux artifacts inside src-tauri/target)
122+
yarn tauri:build
123+
```
124+
125+
Notes:
126+
- The image includes WebKit/GTK dependencies commonly required by Tauri on Linux.
127+
- If additional runtime libraries are needed by your distro, adjust the Dockerfile accordingly.
128+
129+
## Android build (Capacitor + Tauri Android CLI)
130+
131+
Environment variables are already prepared (ANDROID_SDK_ROOT, NDK_HOME). Typical flows:
132+
133+
Build release APK/AAB (without launching emulator):
134+
135+
```bash
136+
yarn install
137+
yarn build
138+
# Sync/android build via Capacitor (release)
139+
yarn android:release
140+
# or build via Tauri Android
141+
# This uses tauri-cli scripts and expects Android SDK/NDK already in place
142+
yarn tauri:build:android
143+
```
144+
145+
Running an Android emulator inside a container is possible but not recommended (GPU, X11/Wayland, KVM). Prefer using an emulator or device on the host, then use ADB over TCP/IP or USB passthrough.
146+
147+
### Using ADB with a USB device (optional, Linux only)
148+
149+
```bash
150+
docker run --rm -it \
151+
--privileged \
152+
-v /dev/bus/usb:/dev/bus/usb \
153+
-v "$PWD":/app \
154+
-v android-sdk:/usr/local/android-sdk \
155+
bf-configurator:dev
156+
157+
# inside the container
158+
$ANDROID_SDK_ROOT/platform-tools/adb devices
159+
```
160+
161+
Alternatively, expose ADB over TCP/IP from the host/emulator and connect from inside the container.
162+
163+
## Gradle 9 — do we need to install it?
164+
165+
- This project uses the Gradle Wrapper located under `android/gradle/wrapper/gradle-wrapper.properties`.
166+
- Current wrapper version: `gradle-8.10.2` (as pinned by `distributionUrl`).
167+
- The Docker image does not install a global Gradle; you don’t need it. The wrapper will download the correct Gradle version automatically.
168+
169+
If you specifically want Gradle 9:
170+
171+
- Update the wrapper to a Gradle 9.x distribution (only if your Android Gradle Plugin and build are compatible):
172+
173+
```bash
174+
# inside the container or on your host (JDK 17+)
175+
cd tauri/betaflight-configurator/android
176+
./gradlew wrapper --gradle-version 9.0 --distribution-type all
177+
# commit the updated gradle/wrapper files
178+
```
179+
180+
- Then rebuild. If issues arise, revert to the pinned version or update AGP accordingly.
181+
182+
Recommendation: keep using the wrapper as-is (8.10.2) unless you have a specific need and have validated plugin compatibility.
183+
184+
## Common pitfalls and tips
185+
186+
- Node version: The image uses Node 22; `package.json` engines specify Node 20.x. This may produce warnings. If you hit issues, switch the Dockerfile to Node 20.x or set Yarn to ignore engines:
187+
188+
```bash
189+
yarn config set ignore-engines true
190+
```
191+
192+
- Caching: Use the named volumes above to avoid re-downloading SDKs and toolchains every run.
193+
- Permissions: Files created by the `developer` user inside the container will be owned by your host user if your UID/GID differs. Adjust with `--user` if needed.
194+
- Not tested yet: Treat this as a baseline. Please update this doc after first successful Android and desktop builds.
195+
196+
## Quick start recap
197+
198+
```bash
199+
# 1) Build image from repo root
200+
docker build -t bf-configurator:dev -f tauri/betaflight-configurator/DockerFile .
201+
202+
# 2) Start a shell with caches and repo mounted
203+
docker run --rm -it -v "$PWD":/app -v android-sdk:/usr/local/android-sdk bf-configurator:dev
204+
205+
# 3) Inside the container
206+
cd /app/tauri/betaflight-configurator
207+
yarn install
208+
yarn build # web assets
209+
yarn tauri:build # desktop app
210+
# or
211+
yarn tauri:build:android # Android build
212+
```

0 commit comments

Comments
 (0)