-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.layer2
More file actions
181 lines (151 loc) · 8.33 KB
/
Dockerfile.layer2
File metadata and controls
181 lines (151 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Layer 2: Flutter Bench Image
# Extends Layer 1 (devbench-base) with Flutter-specific tools
# Includes: Flutter SDK, Android SDK, Dart tools, mobile dev tools
ARG BASE_IMAGE=devbench-base:latest
FROM ${BASE_IMAGE}
# Container version labels
LABEL layer="2"
LABEL layer.name="flutter-bench"
LABEL layer.version="1.0.0"
LABEL layer.description="Flutter and mobile development tools"
LABEL bench.type="flutter"
# Everything runs as root — user personalization happens in Layer 3
USER root
# ========================================
# FLUTTER/ANDROID PREREQUISITES
# ========================================
# Install Flutter/Android prerequisites
RUN apt-get update && apt-get install -y \
libglu1-mesa \
android-tools-adb \
android-tools-fastboot \
&& rm -rf /var/lib/apt/lists/*
# ========================================
# JAVA JDK (FOR ANDROID DEVELOPMENT)
# ========================================
RUN apt-get update && apt-get install -y \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*
# ========================================
# ANDROID SDK INSTALLATION
# ========================================
RUN mkdir -p /opt/android-sdk \
&& wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdtools.zip \
&& unzip -q /tmp/cmdtools.zip -d /opt/android-sdk \
&& rm /tmp/cmdtools.zip \
&& mv /opt/android-sdk/cmdline-tools /opt/android-sdk/cmdline-tools-temp \
&& mkdir -p /opt/android-sdk/cmdline-tools/latest \
&& mv /opt/android-sdk/cmdline-tools-temp/* /opt/android-sdk/cmdline-tools/latest/ \
&& rmdir /opt/android-sdk/cmdline-tools-temp \
&& chown -R root:root /opt/android-sdk \
&& chmod -R 775 /opt/android-sdk
# Set Android SDK environment variables
ENV ANDROID_HOME="/opt/android-sdk"
ENV ANDROID_SDK_ROOT="/opt/android-sdk"
ENV PATH="$PATH:/opt/android-sdk/platform-tools:/opt/android-sdk/emulator:/opt/android-sdk/cmdline-tools/latest/bin"
# Install essential Android SDK components
RUN yes | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses \
&& /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager \
"platform-tools" \
"emulator" \
"cmake;3.22.1" \
"ndk;27.0.12077973" \
"build-tools;33.0.0" \
"build-tools;34.0.0" \
"platforms;android-30" \
"platforms;android-31" \
"platforms;android-32" \
"platforms;android-33" \
"platforms;android-34" \
"platforms;android-35" \
"platforms;android-36" \
"system-images;android-34;google_apis;x86_64" \
&& chmod -R 775 /opt/android-sdk
# ========================================
# FLUTTER ECOSYSTEM
# ========================================
# Install Flutter SDK
ENV FLUTTER_HOME="/opt/flutter"
ENV PATH="$FLUTTER_HOME/bin:$FLUTTER_HOME/bin/cache/dart-sdk/bin:$PATH"
# Install Flutter with fallback
RUN (git clone https://github.com/flutter/flutter.git $FLUTTER_HOME \
&& cd $FLUTTER_HOME \
&& git checkout stable \
&& $FLUTTER_HOME/bin/flutter config --no-analytics) || \
(echo "⚠️ Flutter git clone failed, using direct download fallback..." && \
FLUTTER_VERSION="3.16.5" && \
curl -fsSL --retry 3 --user-agent "Mozilla/5.0" \
https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz | tar -xJC /opt \
&& $FLUTTER_HOME/bin/flutter config --no-analytics) || \
echo "❌ Flutter installation failed completely, skipping..."
# Install Flutter/Dart-specific tools with fallback
RUN $FLUTTER_HOME/bin/dart pub global activate fvm || echo "❌ FVM installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate very_good_cli || echo "❌ Very Good CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate mason_cli || echo "❌ Mason CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate flutterfire_cli || echo "❌ FlutterFire CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate dart_code_metrics || echo "❌ Dart Code Metrics installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate build_runner || echo "❌ Build Runner installation failed, skipping..."
# Install additional essential Flutter development tools
RUN $FLUTTER_HOME/bin/dart pub global activate flutter_gen || echo "❌ Flutter Gen installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate flutter_launcher_icons || echo "❌ Flutter Launcher Icons installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate flutter_native_splash || echo "❌ Flutter Native Splash installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate intl_utils || echo "❌ Intl Utils installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate rename || echo "❌ Rename tool installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate get_cli || echo "❌ GetX CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate bloc_cli || echo "❌ Bloc CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate patrol_cli || echo "❌ Patrol CLI installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate melos || echo "❌ Melos installation failed, skipping..."
RUN $FLUTTER_HOME/bin/dart pub global activate alchemist || echo "❌ Alchemist installation failed, skipping..."
# ========================================
# MOBILE DEVELOPMENT TOOLS
# ========================================
# Install Firebase CLI with fallback
RUN (curl -fsSL --retry 3 --user-agent "Mozilla/5.0" \
https://firebase.tools/bin/linux/latest | bash) || \
(echo "⚠️ Firebase CLI script failed, using npm fallback..." && \
npm install -g firebase-tools) || \
echo "❌ Firebase CLI installation failed completely, skipping..."
# Install additional mobile development tools
RUN apt-get update && apt-get install -y \
gradle \
&& rm -rf /var/lib/apt/lists/*
# Install Fastlane (mobile deployment automation) with fallback
RUN (curl -fsSL --retry 3 --user-agent "Mozilla/5.0" \
https://raw.githubusercontent.com/fastlane/fastlane/master/install | bash -s -- -b /usr/local/bin) || \
echo "❌ Fastlane installation failed, skipping..."
# Install CocoaPods for iOS development with fallback
RUN (gem install cocoapods) || \
echo "❌ CocoaPods installation failed, skipping..."
# Install Sentry CLI for error tracking with fallback
RUN (curl -fsSL --retry 3 --user-agent "Mozilla/5.0" \
https://sentry.io/get-cli/ | bash) || \
(echo "⚠️ Sentry CLI script failed, using npm fallback..." && \
npm install -g @sentry/cli) || \
echo "❌ Sentry CLI installation failed completely, skipping..."
# Install Shorebird for code push updates with fallback
RUN (curl -fsSL --retry 3 --user-agent "Mozilla/5.0" \
https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh | bash) || \
echo "❌ Shorebird installation failed, skipping..."
# Install Figma CLI for design workflow with fallback
RUN (npm install -g @figma/figma-api) || \
echo "❌ Figma CLI installation failed, skipping..."
# ========================================
# ENVIRONMENT & SHELL CONFIGURATION (into /etc/skel)
# ========================================
# Set Java home
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
# Ensure Flutter SDK is group-writable (Layer 3 adds user to root group for write access)
RUN chown -R root:root $FLUTTER_HOME && chmod -R 775 $FLUTTER_HOME
# Add Flutter and Android environment to /etc/skel shell configs
RUN echo '' >> /etc/skel/.zshrc && \
echo '# Flutter/Android environment' >> /etc/skel/.zshrc && \
echo 'export FLUTTER_HOME="/opt/flutter"' >> /etc/skel/.zshrc && \
echo 'export ANDROID_HOME="/opt/android-sdk"' >> /etc/skel/.zshrc && \
echo 'export ANDROID_SDK_ROOT="/opt/android-sdk"' >> /etc/skel/.zshrc && \
echo 'export PATH="$FLUTTER_HOME/bin:$FLUTTER_HOME/bin/cache/dart-sdk/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH:$HOME/.pub-cache/bin"' >> /etc/skel/.zshrc && \
echo 'export ADB_SERVER_SOCKET=tcp:host.docker.internal:5037' >> /etc/skel/.zshrc
# Pre-download Flutter dependencies and accept Android licenses
RUN flutter doctor --android-licenses || true \
&& flutter precache || true
# Default command
CMD ["sleep", "infinity"]