Skip to content

Commit 46559bd

Browse files
authored
Merge pull request #43 from Githubguy132010/Fix-dockerfile
Fix: Update Dockerfile to enhance Android SDK and Flutter setup
2 parents 49ebb46 + bb9283a commit 46559bd

1 file changed

Lines changed: 51 additions & 5 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM ubuntu:22.04
44
# Set working directory
55
WORKDIR /workspace
66

7-
# Install dependencies
7+
# Install dependencies for Linux toolchain and Android SDK
88
RUN apt-get update && \
99
apt-get install -y \
1010
curl \
@@ -15,18 +15,64 @@ RUN apt-get update && \
1515
libglu1-mesa \
1616
openjdk-17-jdk \
1717
sudo \
18+
# Linux toolchain dependencies
19+
clang \
20+
cmake \
21+
ninja-build \
22+
pkg-config \
23+
libgtk-3-dev \
24+
mesa-utils \
25+
# Android SDK dependencies
26+
libc6-dev-i386 \
27+
lib32stdc++6 \
28+
lib32gcc-s1 \
29+
lib32ncurses6 \
30+
lib32z1 \
1831
&& rm -rf /var/lib/apt/lists/*
1932

2033
# Create vscode user
2134
RUN groupadd --gid 1000 vscode && \
2235
useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode && \
2336
echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
2437

38+
# Install Android SDK
39+
ENV ANDROID_SDK_ROOT=/opt/android-sdk
40+
RUN mkdir -p ${ANDROID_SDK_ROOT} && \
41+
chown -R vscode:vscode ${ANDROID_SDK_ROOT}
42+
43+
# Download and install Android Command Line Tools
44+
RUN curl -o /tmp/commandlinetools-linux-14742923_latest.zip https://dl.google.com/android/repository/commandlinetools-linux-14742923_latest.zip && \
45+
unzip -q /tmp/commandlinetools-linux-14742923_latest.zip -d ${ANDROID_SDK_ROOT} && \
46+
rm /tmp/commandlinetools-linux-14742923_latest.zip && \
47+
chown -R vscode:vscode ${ANDROID_SDK_ROOT}
48+
49+
ENV PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${PATH}"
50+
2551
# Install Flutter SDK
2652
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter -b stable && \
27-
chown -R vscode:vscode /usr/local/flutter
53+
chown -R vscode:vscode /usr/local/flutter && \
54+
chmod -R 755 /usr/local/flutter
2855
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
2956

30-
# Accept Flutter licenses and pre-cache
31-
RUN git config --global --add safe.directory /usr/local/flutter
32-
RUN flutter doctor -v && yes | flutter doctor --android-licenses
57+
# Accept Flutter licenses and pre-cache as vscode user
58+
USER vscode
59+
60+
# Configure Android SDK path for Flutter
61+
RUN flutter config --android-sdk ${ANDROID_SDK_ROOT}
62+
63+
# Install Android components - move extracted cmdline tools into latest directory
64+
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools/latest && \
65+
find ${ANDROID_SDK_ROOT}/cmdline-tools -maxdepth 1 -not -name 'latest' -not -path "${ANDROID_SDK_ROOT}/cmdline-tools" -exec mv {} ${ANDROID_SDK_ROOT}/cmdline-tools/latest/ \; 2>/dev/null || true
66+
67+
# Accept Android licenses and install required SDK components
68+
RUN yes | sdkmanager --licenses && \
69+
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
70+
71+
# Accept Flutter and Android licenses
72+
RUN git config --global --add safe.directory /usr/local/flutter && \
73+
git config --global --add safe.directory /workspace && \
74+
flutter doctor -v && \
75+
yes | flutter doctor --android-licenses
76+
77+
# Switch back to root for any additional setup
78+
USER root

0 commit comments

Comments
 (0)