Skip to content

Commit d7e6c4b

Browse files
committed
Add Gitpod configuration
1 parent ba1a463 commit d7e6c4b

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
2+
# RUN useradd -u 3333 -G sudo -m -d /home/gitpod -s /bin/bash gitpod && echo "gitpod:gitpod" | chpasswd \
3+
# && sed -i.bkp -e '/Defaults\tuse_pty/d' -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers
4+
USER vscode
5+
ENV HOME=/home/vscode
6+
# SHELL ["/bin/bash", "-c"]
7+
8+
# # use this Dockerfile to install additional tools you might need, e.g.
9+
# # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
10+
# # && apt-get -y install --no-install-recommends <your-package-list-here>
11+
12+
ENV ANDROID_HOME=$HOME/android-sdk
13+
ENV PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/bootstrap/bin:$ANDROID_HOME/platform-tools:$PATH"
14+
ENV PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH"
15+
16+
# Install Android SDK
17+
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
&& sudo apt-get -y install --no-install-recommends \
19+
curl \
20+
unzip \
21+
openjdk-21-jdk
22+
23+
RUN version="9477386" && mkdir -p $ANDROID_HOME/cmdline-tools/bootstrap \
24+
&& curl -L https://dl.google.com/android/repository/commandlinetools-linux-${version}_latest.zip -o /tmp/cmdline-tools.zip \
25+
&& unzip -q /tmp/cmdline-tools.zip -d /tmp/unzip && mv /tmp/unzip/*/* $ANDROID_HOME/cmdline-tools/bootstrap
26+
27+
RUN yes | sdkmanager --licenses \
28+
&& sdkmanager "cmdline-tools;latest" \
29+
&& sdkmanager \
30+
"platform-tools" \
31+
"build-tools;35.0.0" \
32+
"ndk;28.1.13356709" \
33+
"platforms;android-35" \
34+
"emulator" \
35+
"add-ons;addon-google_apis-google-24" \
36+
"cmake;4.0.2" \
37+
"system-images;android-35;google_apis;x86_64"
38+
39+
# Cold boot the emulator to start it quickly later
40+
RUN avdmanager create avd --name headless_avd --package "system-images;android-35;google_apis;x86_64" --device "pixel" && avdmanager list avd
41+
# RUN if test -e /dev/kvm; then sudo chmod 777 /dev/kvm; (until adb shell getprop sys.boot_completed | grep -q 1; do sleep 2; done && sleep 10 && adb emu kill) & emulator -avd headless_avd -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -accel off -no-metrics; fi
42+
43+
44+
USER root
45+
# Install necessary kernel tools
46+
RUN export DEBIAN_FRONTEND=noninteractive \
47+
&& apt-get -y install --no-install-recommends \
48+
kmod \
49+
cpu-checker \
50+
qemu-system-x86 qemu-utils qemu-kvm \
51+
file
52+
53+
# Install scrcpy
54+
RUN curl -L https://github.com/Genymobile/scrcpy/releases/download/v3.2/scrcpy-linux-x86_64-v3.2.tar.gz -o /tmp/scrcpy.tar.gz \
55+
&& tar -xf /tmp/scrcpy.tar.gz -C /tmp \
56+
&& mv /tmp/scrcpy-linux*/scrcpy /usr/local/bin/scrcpy \
57+
&& chmod +x /usr/local/bin/scrcpy
58+
59+
60+
USER vscode
61+
# Install uv & mysc
62+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
63+
&& curl -fsSL https://fnm.vercel.app/install | bash
64+
# && sudo apt-get install -y portaudio19-dev \
65+
# && uv tool install mysc[web]
66+
67+
# Install ws-scrcpy
68+
SHELL ["/bin/bash", "-lic"]
69+
RUN fnm install --lts \
70+
&& cd $HOME && git clone https://github.com/NetrisTV/ws-scrcpy.git && cd ws-scrcpy \
71+
&& uv run npm install && npm run dist:prod
72+
# && uv run bun install && uv run bun run dist:prod

.devcontainer/devcontainer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// The Dev Container format allows you to configure your environment. At the heart of it
2+
// is a Docker image or Dockerfile which controls the tools available in your environment.
3+
//
4+
// See https://aka.ms/devcontainer.json for more information.
5+
{
6+
"name": "Gitpod",
7+
"remoteUser": "vscode",
8+
// Use "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
9+
// instead of the build to use a pre-built image.
10+
"build": {
11+
"context": ".",
12+
"dockerfile": "Dockerfile"
13+
},
14+
// Features add additional features to your environment. See https://containers.dev/features
15+
// Beware: features are not supported on all platforms and may have unintended side-effects.
16+
// "features": {
17+
// "ghcr.io/devcontainers/features/docker-in-docker:2": {}
18+
// },
19+
"initializeCommand": "modprobe kvm && modprobe kvm_intel && chmod 777 /dev/kvm",
20+
"privileged": true,
21+
"runArgs": [
22+
"--cap-add=ALL",
23+
"--device=/dev/fuse",
24+
"--device=/dev/kvm",
25+
"--device=/dev/snd",
26+
"--device=/dev/video0",
27+
"--security-opt=apparmor:unconfined"
28+
],
29+
"mounts": [
30+
"source=/boot,target=/boot,type=bind",
31+
"source=/lib/modules,target=/lib/modules,type=bind"
32+
]
33+
}

.gitpod/automations.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
services:
2+
android_emulator:
3+
name: Android Emulator
4+
commands:
5+
start: |
6+
echo "Starting Android Emulator..."
7+
adb start-server
8+
emulator -avd headless_avd -port 5554 -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -accel on -no-metrics
9+
ready: adb shell getprop sys.boot_completed 2>/dev/null | grep -q 1
10+
stop: |
11+
# adb -s emulator-5554 emu kill; adb kill-server
12+
PID=$(pgrep -f 'qemu-system-x86_64-headless -avd headless_avd -port 5554')
13+
test -z "$PID" && echo "Emulator process not found" && exit 1
14+
15+
kill -SIGINT "$PID"
16+
while kill -0 "$PID" 2>/dev/null; do
17+
sleep 1
18+
done
19+
20+
echo "Emulator process $PID has exited cleanly."
21+
triggeredBy:
22+
- postEnvironmentStart
23+
24+
emulator_control:
25+
name: Emulator Control Web
26+
commands:
27+
start: |
28+
until adb shell getprop sys.boot_completed 2>/dev/null | grep -q 1; do sleep 1; done
29+
cd ~/ws-scrcpy/dist
30+
node ./index.js
31+
triggeredBy:
32+
- postEnvironmentStart
33+
34+
35+
tasks:
36+
adb_server:
37+
name: ADB Server
38+
command: adb start-server
39+
triggeredBy:
40+
- manual

0 commit comments

Comments
 (0)