Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 609ba71

Browse files
committed
test: move back to dockerfile
1 parent bda6fc1 commit 609ba71

File tree

5 files changed

+68
-33
lines changed

5 files changed

+68
-33
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM codercom/enterprise-base:latest
2+
3+
ARG ANDROID_SDK_VERSION=13114758
4+
ENV ANDROID_SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip"
5+
6+
USER root
7+
8+
# Java
9+
RUN apt update --yes && \
10+
apt install --yes --no-install-recommends \
11+
openjdk-21-jdk \
12+
openjdk-21-jre \
13+
libpulse0 && \
14+
rm -rf /var/lib/apt/lists/*
15+
16+
# TODO: Gradle
17+
18+
# Install the Android commandline tools
19+
ENV ANDROID_HOME="/usr/local/android"
20+
ENV CMDLINE_TOOLS_HOME="${ANDROID_HOME}/cmdline-tools"
21+
22+
RUN mkdir -p "$CMDLINE_TOOLS_HOME" && \
23+
wget "$ANDROID_SDK_URL" -O "/tmp/android-sdk.zip" && \
24+
unzip "/tmp/android-sdk.zip" -d "$CMDLINE_TOOLS_HOME" && \
25+
mv "$CMDLINE_TOOLS_HOME/cmdline-tools" "$CMDLINE_TOOLS_HOME/latest" && \
26+
rm -rf "/tmp/android-sdk.zip"
27+
28+
# Add the command line tools to the path
29+
ENV PATH="${PATH}:${CMDLINE_TOOLS_HOME}/latest/bin"
30+
31+
# Accept sdkmanager licenses
32+
RUN yes | sdkmanager --licenses
33+
34+
# Install required tools, TODO: see why CircleCI installs multiple versions of build-tools
35+
RUN sdkmanager \
36+
"tools" \
37+
"platform-tools" \
38+
"build-tools;34.0.0"
39+
40+
# Install Android and Google's Maven repositories and Google Play services
41+
RUN sdkmanager \
42+
"extras;android;m2repository" \
43+
"extras;google;m2repository" \
44+
"extras;google;google_play_services"
45+
46+
# Install Android platforms and system images
47+
# TODO: see how we handle all the platforms and system images for all the different versions, also diff between google_apis and google_apis_playstore
48+
RUN sdkmanager \
49+
"platforms;android-34" \
50+
"system-images;android-34;google_apis_playstore;x86_64"
51+
52+
# Make the Android SDK folder accessible by all users
53+
RUN chmod 755 "$ANDROID_HOME" -R
54+
55+
# Add all the other Android SDK tools to the path
56+
ENV PATH="${PATH}:${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools"
57+
58+
# Add the "coder" user to the "kvm" group to allow it to use the /dev/kvm device
59+
RUN groupadd -r kvm -g 108 && \
60+
usermod -aG kvm coder
61+
62+
USER coder

docker-android/.devcontainer/devcontainer.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"image": "codercom/enterprise-base:latest",
2+
"build": {
3+
"dockerfile": "./Dockerfile",
4+
},
35

46
"name": "Android in Docker",
57

@@ -18,15 +20,11 @@
1820
},
1921

2022
"features": {
21-
"ghcr.io/phorcys420/devcontainer-features/android-sdk:1": {
23+
/*"ghcr.io/phorcys420/devcontainer-features/android-sdk:1": {
2224
"installMavenRepos": true,
2325
"installPlayServices": true,
2426
"installEmulator": true
25-
},
26-
27-
"./features/android-vm": {
28-
"androidImage": "system-images;android-34;google_apis_playstore;x86_64"
29-
}
27+
}*/
3028

3129
// These features have not been included for the sake of keeping the template "light", but feel free to add them back:
3230
//"ghcr.io/devcontainers-extra/features/gradle-sdkman:2": {},

docker-android/.devcontainer/features/android-vm/devcontainer-feature.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker-android/.devcontainer/features/android-vm/install.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

docker-android/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ module "android-vm" {
206206
source = "./modules/android-vm"
207207

208208
android_device = "pixel_5"
209-
android_image = "system-images;android-34;google_apis_playstore;x86_64"
209+
android_image = "system-images;android-34;google_apis_playstore;x86_64" # TODO: autodetect, and maybe make this a preset
210210

211211
agent_id = coder_agent.main.id
212212
}

0 commit comments

Comments
 (0)