Browse Source

add gitpod

liuyuqi-dellpc 2 months ago
parent
commit
4bfecaf44d

+ 62 - 0
android-studio/.gitpod.Dockerfile

@@ -0,0 +1,62 @@
+FROM gitpod/workspace-full-vnc
+SHELL ["/bin/bash", "-c"]
+
+# install android sdk
+# 采用 commandlinetools 安装,android 30
+USER root
+ENV ANDROID_HOME=/home/gitpod/androidsdk \
+    FLUTTER_VERSION=2.2.3-stable
+
+# Install Open JDK
+USER root
+RUN apt update \
+    && apt install openjdk-8-jdk -y \
+    && update-java-alternatives --set java-1.8.0-openjdk-amd64
+
+# Install SDK Manager commandlinetools
+USER gitpod
+RUN  wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip \
+    && mkdir -p $ANDROID_HOME/cmdline-tools/latest \
+    && unzip commandlinetools-linux-*.zip -d $ANDROID_HOME \
+    && rm -f commandlinetools-linux-*.zip \
+    && mv $ANDROID_HOME/cmdline-tools/bin $ANDROID_HOME/cmdline-tools/latest \
+    && mv $ANDROID_HOME/cmdline-tools/lib $ANDROID_HOME/cmdline-tools/latest
+
+RUN echo "export ANDROID_HOME=$ANDROID_HOME" >> /home/gitpod/.bashrc \
+    && echo 'export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools:$PATH' >> /home/gitpod/.bashrc
+
+# Install Android Image version 30
+USER gitpod
+RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-30" "emulator"
+RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;google_apis;x86_64"
+RUN echo no | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n avd28 -k "system-images;android-30;google_apis;x86_64"
+
+
+# Install Google Chrome
+USER root
+RUN apt-get update \
+    && apt-get install -y apt-transport-https \
+    && curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
+    && echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
+    && apt-get update \
+    && sudo apt-get install -y google-chrome-stable
+
+# misc deps
+RUN apt-get install -y \
+    libasound2-dev \
+    libgtk-3-dev \
+    libnss3-dev \
+    fonts-noto \
+    fonts-noto-cjk
+
+# For Qt WebEngine on docker
+ENV QTWEBENGINE_DISABLE_SANDBOX 1
+
+
+USER gitpod
+# Install Node and Yarn
+ENV NODE_VERSION=10.14
+RUN bash -c ". .nvm/nvm.sh     && nvm install ${NODE_VERSION}     && nvm use ${NODE_VERSION}     && nvm alias default ${NODE_VERSION}"
+RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix
+
+RUN npm install -g nativescript@6.5.1

+ 35 - 0
android-studio/.gitpod.Dockerfile.old

@@ -0,0 +1,35 @@
+FROM gitpod/workspace-full-vnc
+
+# 采用 sdk-tools-linux-4333796 安装 android 28 (有些应用需要在低版本下运行)
+
+# install java1.8
+USER gitpod
+RUN bash -c "source ~/.sdkman/bin/sdkman-init.sh && \
+    sdk install java 8.312.07.1-amzn"
+ENV JAVA_HOME /home/gitpod/.sdkman/candidates/java/8.312.07.1-amzn
+
+
+ENV ANDROID_HOME /opt/android-sdk-linux
+RUN apt update -qq && apt install zip unzip
+RUN cd /opt && \
+    wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && \
+    unzip -q *.zip -d ${ANDROID_HOME} && \
+    rm *.zip
+
+RUN chmod -R 777 ${ANDROID_HOME}
+RUN apt clean -qq
+USER gitpod
+RUN yes | sdkmanager --licenses
+RUN yes | sdkmanager --update --channel=3
+RUN sdkmanager "platform-tools" 'build-tools;28.0.3' 'platforms;android-28' "emulator" 
+RUN sdkmanager "system-images;android-28;google_apis;x86_64"
+RUN avdmanager create avd -n avd28 -k "system-images;android-28;google_apis;x86_64"
+
+ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
+
+# Install Node and Yarn
+ENV NODE_VERSION=10.14
+RUN bash -c ". .nvm/nvm.sh     && nvm install ${NODE_VERSION}     && nvm use ${NODE_VERSION}     && nvm alias default ${NODE_VERSION}"
+RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix
+
+RUN npm install -g nativescript@6.5.1

+ 12 - 0
android-studio/.gitpod.yml

@@ -0,0 +1,12 @@
+image:
+  file: .gitpod.Dockerfile
+  
+tasks:
+  - init: |
+      npm install
+ports:
+  - port: 5900
+    onOpen: ignore
+    # vnc
+  - port: 6080
+    onOpen: open-preview

+ 75 - 10
flutter/.gitpod.Dockerfile

@@ -1,14 +1,79 @@
-FROM gitpod/workspace-full
-                    
+FROM gitpod/workspace-full-vnc
+SHELL ["/bin/bash", "-c"]
+
+# insall flutter and android sdk/ndk/avd/java/gradle 
+ENV ANDROID_HOME=/home/gitpod/androidsdk \
+    FLUTTER_VERSION=2.2.3-stable
+ENV ANDROID_VERSION=30
+
+# Install dart
+USER root
+RUN curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
+    && curl -fsSL https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list \
+    && install-packages build-essential dart libkrb5-dev gcc make gradle android-tools-adb android-tools-fastboot
+
+# Install flutter
+USER gitpod
+RUN cd /home/gitpod \
+    && wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}.tar.xz \
+    && tar -xvf flutter*.tar.xz \
+    && rm -f flutter*.tar.xz
+
+RUN flutter/bin/flutter precache
+RUN echo 'export PATH="$PATH:/home/gitpod/flutter/bin"' >> /home/gitpod/.bashrc
+
+USER root
+
+# Install Open JDK
+USER root
+RUN apt update \
+    && apt install openjdk-8-jdk -y \
+    && update-java-alternatives --set java-1.8.0-openjdk-amd64
+
+# Install SDK Manager
 USER gitpod
+RUN  wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip \
+    && mkdir -p $ANDROID_HOME/cmdline-tools/latest \
+    && unzip commandlinetools-linux-*.zip -d $ANDROID_HOME \
+    && rm -f commandlinetools-linux-*.zip \
+    && mv $ANDROID_HOME/cmdline-tools/bin $ANDROID_HOME/cmdline-tools/latest \
+    && mv $ANDROID_HOME/cmdline-tools/lib $ANDROID_HOME/cmdline-tools/latest
 
-WORKDIR /home/gitpod
+RUN echo "export ANDROID_HOME=$ANDROID_HOME" >> /home/gitpod/.bashrc \
+    && echo 'export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools:$PATH' >> /home/gitpod/.bashrc
 
-RUN git clone https://github.com/flutter/flutter && \
-    /home/gitpod/flutter/bin/flutter channel master && \
-    /home/gitpod/flutter/bin/flutter upgrade && \
-    /home/gitpod/flutter/bin/flutter config --enable-web && \
-    /home/gitpod/flutter/bin/flutter --version
+# Install Android Image version $ANDROID_VERSION
+USER gitpod
+RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-$ANDROID_VERSION" "emulator" 'build-tools;28.0.3'
+RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-$ANDROID_VERSION;google_apis;x86_64"
+RUN echo no | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n avd28 -k "system-images;android-$ANDROID_VERSION;google_apis;x86_64"
+
+
+# Install Google Chrome
+USER root
+RUN apt-get update \
+    && apt-get install -y apt-transport-https \
+    && curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
+    && echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
+    && apt-get update \
+    && sudo apt-get install -y google-chrome-stable
+
+# misc deps
+RUN apt-get install -y \
+    libasound2-dev \
+    libgtk-3-dev \
+    libnss3-dev \
+    fonts-noto \
+    fonts-noto-cjk
+
+# For Qt WebEngine on docker
+ENV QTWEBENGINE_DISABLE_SANDBOX 1
+
+
+USER gitpod
+# Install Node and Yarn
+ENV NODE_VERSION=10.14
+RUN bash -c ". .nvm/nvm.sh     && nvm install ${NODE_VERSION}     && nvm use ${NODE_VERSION}     && nvm alias default ${NODE_VERSION}"
+RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix
 
-ENV PUB_CACHE=/workspace/.pub_cache
-ENV PATH="/home/gitpod/flutter/bin:$PATH"
+RUN npm install -g nativescript@6.5.1

+ 62 - 3
flutter/.gitpod.yml

@@ -6,10 +6,69 @@ tasks:
       flutter upgrade
       flutter update-packages --force-upgrade
       flutter run -d web-server --no-resident
+
+
+tasks:
+  - init: |
+      flutter channel beta
+      flutter upgrade
+      flutter config --enable-web
+      flutter config --android-sdk /home/gitpod/androidsdk
+      echo y | flutter doctor --android-licenses
+      flutter doctor
+      flutter pub get
+      # flutter build -v bundle
+      # flutter build -v web
+      # flutter build -v appbundle
+      flutter build -v apk
+      
+  - command: |
+      # Gitpod is not able to run emulators within a worspace at this stage as
+      # Google Kubernetes Engine does not support Nested Virtualization.
+      #
+      # If running Gitpod on your own infrastructure or via the Dockerfile locally
+      # on infrastructure that exposes vmx or svm then this command will launch
+      # the emulator.
+      #
+      # $ emulator -avd avd28 -no-audio -no-window 
+      #
+      # Until this restriction is mitigated you can run native mobile apps in your
+      # browser via https://appetize.io/
+      if [[ -z "$APPETIZE_API_TOKEN" ]]; then
+          echo "Appetize API token not set. Run:"
+          echo ""
+          echo "    gp env APPETIZE_API_TOKEN=your_token"
+          echo ""
+          echo "and restart this workspace in order to get an app preview."
+          echo ""
+          echo "Request your token here: https://appetize.io/docs#request-api-token"
+      else
+          curl -sS --http1.1 "https://$APPETIZE_API_TOKEN@api.appetize.io/v1/apps/$APPETIZE_PUBLICKEY" \
+              -F "file=@/workspace/template-flutter/build/app/outputs/flutter-apk/app.apk" \
+              -F platform=android \
+              -F "buttonText=Start App" \
+              -F "postSessionButtonText=Start App" \
+              > .appetize.json
+          APPETIZE_PUBLICKEY=$(jq -r .publicKey .appetize.json)
+          gp env "APPETIZE_PUBLICKEY=$APPETIZE_PUBLICKEY"
+          export APPETIZE_PUBLICKEY
+          python -m webbrowser "https://appetize.io/embed/$APPETIZE_PUBLICKEY?device=pixel4&autoplay=true"
+      fi
+      flutter devices
+    
+      flutter run --web-port 8080
+
+
 ports:
+  - port: 5900
+    onOpen: ignore
+    # vnc
+  - port: 6080
+    onOpen: open-preview
+    # flutter
   - port: 8080
-    onOpen: notify
+    onOpen: open-preview
+
 vscode:
   extensions:
-    - Dart-Code.dart-code@3.10.0-beta.2:tUOuxmX97tnVRlRhi8Z1og==
-    - Dart-Code.flutter@3.9.1:Ef3b5HLzz0C/TIa0n9xSyA==
+    - dart-code.flutter@3.9.1:Ef3b5HLzz0C/TIa0n9xSyA==