Mrgf9993 commited on
Commit
f154923
·
verified ·
1 Parent(s): 8e095ab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -29
Dockerfile CHANGED
@@ -1,50 +1,63 @@
1
  FROM ubuntu:22.04
2
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PUB_CACHE=/home/user/.pub-cache
5
- ENV ANDROID_HOME=/opt/android-sdk
6
- ENV ANDROID_SDK_ROOT=$ANDROID_HOME
7
- ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
8
- ENV PATH="/opt/flutter/bin:/opt/flutter/bin/cache/dart-sdk/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:${PATH}"
9
 
10
- # Install system dependencies
11
  RUN apt-get update && apt-get install -y \
12
- curl git unzip xz-utils zip libglu1-mesa \
13
- python3 python3-pip wget openjdk-17-jdk \
14
- libc6 libncurses5 libstdc++6 lib32z1 libbz2-1.0 \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
- # Install code-server
18
  RUN curl -fsSL https://code-server.dev/install.sh | sh
19
 
20
- # Install Flutter
21
- RUN git clone https://github.com/flutter/flutter.git -b stable /opt/flutter
22
 
23
- # Install Android Command Line Tools
24
- RUN mkdir -p $ANDROID_HOME/cmdline-tools && \
25
- cd $ANDROID_HOME/cmdline-tools && \
26
- wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdline-tools.zip && \
27
- unzip -q cmdline-tools.zip && \
28
- mv cmdline-tools latest && \
29
- rm cmdline-tools.zip
30
 
31
- # Accept Android licenses non-interactively
32
- RUN yes | flutter doctor --android-licenses 2>/dev/null || true
33
-
34
- # Create user and set permissions
35
  RUN useradd -m -u 1000 user && \
36
- chown -R user:user /opt/flutter $ANDROID_HOME /home/user
 
37
 
38
  USER user
39
  WORKDIR /home/user
40
 
41
- # Pre-cache Flutter artifacts and run doctor
42
- RUN flutter precache --android && \
43
- flutter doctor -v
44
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  COPY --chown=user requirements.txt .
46
- RUN pip3 install --no-cache-dir -r requirements.txt
47
 
48
  EXPOSE 7860
49
 
50
- CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "."]
 
1
  FROM ubuntu:22.04
2
 
3
+ # 1. Environment Variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV PUB_CACHE=/home/user/.pub-cache
6
+ ENV ANDROID_SDK_ROOT=/opt/android-sdk
7
+ # Merged PATH for Flutter, Dart, and Android Tools
8
+ ENV PATH="/opt/flutter/bin:/opt/flutter/bin/cache/dart-sdk/bin:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${PATH}"
 
9
 
10
+ # 2. Install System Dependencies
11
  RUN apt-get update && apt-get install -y \
12
+ curl git unzip xz-utils zip libglu1-mesa python3 python3-pip wget openjdk-17-jdk \
 
 
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # 3. Install code-server
16
  RUN curl -fsSL https://code-server.dev/install.sh | sh
17
 
18
+ # 4. Install Flutter SDK
19
+ RUN git clone https://github.com/flutter/flutter.git /opt/flutter
20
 
21
+ # 5. Install Android SDK Command Line Tools
22
+ # Note: Using version 11076708 (adjust if a newer version is required)
23
+ RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
24
+ wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/tools.zip && \
25
+ unzip /tmp/tools.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
26
+ mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest && \
27
+ rm /tmp/tools.zip
28
 
29
+ # 6. Setup User and Permissions
 
 
 
30
  RUN useradd -m -u 1000 user && \
31
+ chown -R user:user /opt/flutter && \
32
+ chown -R user:user ${ANDROID_SDK_ROOT}
33
 
34
  USER user
35
  WORKDIR /home/user
36
 
37
+ # 7. Configure Android SDK & Licenses
38
+ # Accepts all licenses and installs basic platform tools
39
+ RUN yes | sdkmanager --licenses && \
40
+ sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
41
+
42
+ # 8. Activate Flutter and Extensions
43
+ RUN flutter config --android-sdk ${ANDROID_SDK_ROOT} && \
44
+ flutter precache && \
45
+ flutter doctor && \
46
+ code-server --install-extension dart-code.flutter && \
47
+ code-server --install-extension dart-code.dart-code
48
+
49
+ # 9. Optional: Pre-configure VS Code Settings
50
+ RUN mkdir -p /home/user/.local/share/code-server/User && \
51
+ echo '{ \
52
+ "dart.flutterSdkPath": "/opt/flutter", \
53
+ "dart.sdkPath": "/opt/flutter/bin/cache/dart-sdk", \
54
+ "python.defaultInterpreterPath": "/usr/bin/python3" \
55
+ }' > /home/user/.local/share/code-server/User/settings.json
56
+
57
+ # 10. Final Setup
58
  COPY --chown=user requirements.txt .
59
+ RUN pip3 install --no-cache-dir -r requirements.txt || echo "No requirements.txt found, skipping..."
60
 
61
  EXPOSE 7860
62
 
63
+ CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "."]