Skip to content

Commit 1ad2edc

Browse files
committed
Dockerfile
1 parent dee1fd4 commit 1ad2edc

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

container/Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Build with:
2+
# podman build -t scrcpy-builder .
3+
#
4+
# Run with:
5+
# podman run \
6+
# -v PATH_TO_SCRCPY:/home/debian/scrcpy \
7+
# --userns=keep-id \
8+
# -it scrcpy-builder \
9+
# bash
10+
11+
FROM debian:trixie
12+
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
15+
RUN apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
sudo wget unzip gcc git pkg-config meson ninja-build cmake \
18+
libsdl3-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
19+
libswresample-dev libusb-1.0-0-dev openjdk-21-jdk \
20+
mingw-w64 mingw-w64-tools libz-mingw-w64-dev
21+
22+
RUN groupadd -g 1000 debian \
23+
&& useradd -m -u 1000 -g 1000 -s /bin/bash debian
24+
RUN echo "debian ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
25+
26+
ENV ANDROID_HOME=/opt/android/sdk
27+
RUN mkdir -p "$ANDROID_HOME" \
28+
&& chown debian:debian "$ANDROID_HOME"
29+
30+
USER debian
31+
WORKDIR /home/debian
32+
33+
ENV CMDLINETOOLS_URL=https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip
34+
ENV CMDLINETOOLS_SHA256=7ec965280a073311c339e571cd5de778b9975026cfcbe79f2b1cdcb1e15317ee
35+
36+
RUN wget -q "$CMDLINETOOLS_URL" -O cmdlinetools.zip \
37+
&& echo "$CMDLINETOOLS_SHA256 cmdlinetools.zip" | sha256sum -c
38+
39+
RUN mkdir tmp \
40+
&& unzip -q cmdlinetools.zip -d tmp \
41+
&& mkdir -p "$ANDROID_HOME/cmdline-tools" \
42+
&& mv tmp/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest" \
43+
&& rmdir tmp \
44+
&& rm cmdlinetools.zip
45+
# To get the licence hash, run manually: "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses
46+
# Build-tools 35 is still needed for the current AGP version
47+
RUN mkdir -p "$ANDROID_HOME/licenses" \
48+
&& echo 24333f8a63b6825ea9c5514f83c2829b004d1fee > "$ANDROID_HOME/licenses/android-sdk-license" \
49+
&& $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-36" "build-tools;35.0.0" "build-tools;36.0.0"
50+
51+
# For scrcpy build scripts
52+
ENV GRADLE_VERSION=8.14.3
53+
ENV GRADLE_HOME=/opt/gradle-$GRADLE_VERSION
54+
ENV GRADLE_URL=https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip
55+
ENV GRADLE_SHA256=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
56+
ENV GRADLE=gradle
57+
ENV PATH=$GRADLE_HOME/bin:$PATH
58+
59+
USER root
60+
RUN wget -q "$GRADLE_URL" -O gradle.zip \
61+
&& echo "$GRADLE_SHA256 gradle.zip" | sha256sum -c
62+
RUN unzip -q gradle.zip -d /opt \
63+
&& rm gradle.zip
64+
65+
USER debian
66+
67+
# Pre-download gradle dependencies for scrcpy
68+
RUN mkdir -p /home/debian/fake-scrcpy/app
69+
COPY fake.gradle /home/debian/fake-scrcpy/build.gradle
70+
COPY fake_app.gradle /home/debian/fake-scrcpy/app/build.gradle
71+
RUN echo "include ':app'" > /home/debian/fake-scrcpy/settings.gradle \
72+
&& gradle -p /home/debian/fake-scrcpy dependencies androidDependencies --no-daemon \
73+
&& rm -rf /home/debian/fake-scrcpy

container/fake.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Fake build.gradle to pre-download gradle dependencies
2+
buildscript {
3+
repositories {
4+
google()
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:8.13.0'
9+
}
10+
}
11+
12+
allprojects {
13+
repositories {
14+
google()
15+
mavenCentral()
16+
}
17+
}

container/fake_app.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Fake app/build.gradle to pre-download gradle dependencies
2+
apply plugin: 'com.android.application'
3+
apply plugin: 'checkstyle'
4+
5+
android {
6+
buildToolsVersion = "36.0.0"
7+
namespace = "com.genymobile.scrcpy"
8+
compileSdk 36
9+
defaultConfig {
10+
minSdkVersion 21
11+
targetSdkVersion 36
12+
}
13+
}
14+
15+
checkstyle {
16+
toolVersion = '10.12.5'
17+
}
18+
19+
dependencies {
20+
testImplementation 'junit:junit:4.13.2'
21+
}

0 commit comments

Comments
 (0)