Browse Source

chore: update Dockerfile and docker-compose configurations

liuyuqi-dellpc 6 months ago
parent
commit
566d53d998

+ 1 - 0
R/.ide/Dockerfile

@@ -0,0 +1 @@
+FROM sift-docker.pkg.coding.net/flutter-team/dev-container/dev-allinone:1.0.12-r

+ 253 - 0
R/.ide/Dockerfile-Allinone-flutter

@@ -0,0 +1,253 @@
+FROM ubuntu:24.04 as builder
+LABEL email="liuyuqi<liuyuqi.gov@msn.cn>"
+
+USER root
+# apt change to aliyun
+RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list.d/ubuntu.sources
+RUN sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list.d/ubuntu.sources
+
+RUN apt-get update && apt-get install -y \
+    curl zip unzip wget git vim build-essential
+
+# install java
+RUN curl -s "https://get.sdkman.io" | bash
+RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install java 17.0.11-ms"
+ENV JAVA_HOME /root/.sdkman/candidates/java/17.0.11-ms
+ENV PATH=$PATH:$JAVA_HOME/bin
+
+ENV MAVEN_VERSION=3.9.5 \
+    GRADLE_VERSION=7.5
+
+# install gradle
+RUN wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -P /tmp
+RUN unzip -d /opt/gradle /tmp/gradle-*.zip && rm -rf /tmp/gradle-*.zip
+ENV GRADLE_HOME=/opt/gradle/gradle-${GRADLE_VERSION}
+ENV PATH=$PATH:$GRADLE_HOME/bin
+
+# install maven
+RUN wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.zip -P /tmp
+RUN unzip -d /opt/maven /tmp/apache-maven-*.zip
+ENV MAVEN_HOME=/opt/maven/apache-maven-${MAVEN_VERSION}
+ENV PATH=$PATH:$MAVEN_HOME/bin
+
+# install android sdk
+ENV ANDROID_HOME=/opt/androidsdk \
+    FLUTTER_HOME=/opt/flutter
+
+RUN wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_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" >> ~/.bashrc \
+    && echo 'export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools:$PATH' >> ~/.bashrc
+
+ENV PATH=$PATH:$FLUTTER_HOME/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/emulator
+RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --verbose "platform-tools" "platforms;android-33"
+
+ENV PUB_HOSTED_URL=https://pub.flutter-io.cn
+ENV FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
+
+# install flutter
+ARG FLUTTER_VERSION="3.13.5"
+RUN git clone --branch ${FLUTTER_VERSION} https://github.com/flutter/flutter.git ${FLUTTER_HOME} \
+    && cd ${FLUTTER_HOME} \
+    && ./bin/flutter precache \
+    && ./bin/flutter doctor
+
+RUN curl -fsSL https://fvm.app/install.sh | bash
+
+# install python
+RUN mkdir -p ~/.pip
+RUN echo '\n\
+    [global] \n\
+    trusted-host=mirrors.aliyun.com \n\
+    index-url=https://mirrors.aliyun.com/pypi/simple/ \n\
+    ' > ~/.pip/pip.conf
+
+ARG PYTHON_MAJ_VERSION=3.12
+ARG PYTHON_PATCH_VERSION=1
+ARG PYTHON_VERSION=${PYTHON_MAJ_VERSION}.${PYTHON_PATCH_VERSION}
+
+RUN apt-get update && \
+    apt-get install -y \
+    make \
+    build-essential \
+    libssl-dev \
+    zlib1g-dev \
+    libbz2-dev \
+    libreadline-dev \
+    libsqlite3-dev \
+    curl \
+    llvm \
+    libncurses5-dev \
+    libncursesw5-dev \
+    xz-utils \
+    tk-dev python3-dev default-libmysqlclient-dev libpq-dev
+RUN curl -O https://mirrors.huaweicloud.com/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
+    tar xzf Python-${PYTHON_VERSION}.tgz && \
+    rm Python-${PYTHON_VERSION}.tgz && \
+    cd Python-${PYTHON_VERSION} && \
+    ./configure --prefix=/opt/python/${PYTHON_VERSION}/ --enable-optimizations --with-lto --with-computed-gotos --with-system-ffi && \
+    make -j "$(nproc)" && \
+    make altinstall
+
+RUN /opt/python/${PYTHON_VERSION}/bin/python${PYTHON_MAJ_VERSION} -m pip install --upgrade pip setuptools wheel poetry && \
+    ln -s /opt/python/${PYTHON_VERSION}/bin/python${PYTHON_MAJ_VERSION}  /opt/python/${PYTHON_VERSION}/bin/python3 && \
+    ln -s /opt/python/${PYTHON_VERSION}/bin/python${PYTHON_MAJ_VERSION}  /opt/python/${PYTHON_VERSION}/bin/python && \
+    ln -s /opt/python/${PYTHON_VERSION}/bin/pydoc${PYTHON_MAJ_VERSION}   /opt/python/${PYTHON_VERSION}/bin/pydoc && \
+    ln -s /opt/python/${PYTHON_VERSION}/bin/idle${PYTHON_MAJ_VERSION}    /opt/python/${PYTHON_VERSION}/bin/idle && \
+    ln -s /opt/python/${PYTHON_VERSION}/bin/python${PYTHON_MAJ_VERSION}-config /opt/python/${PYTHON_VERSION}/bin/python-config
+ENV PATH=/opt/python/${PYTHON_VERSION}/bin:${PATH}
+
+RUN git clone --depth 1 https://github.com/pyenv/pyenv.git ~/.pyenv && \
+    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \
+    echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc && \
+    echo 'eval "$(pyenv init -)"' >> ~/.bashrc
+
+ENV PATH=$PATH:/root/.pyenv/bin
+ENV PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1
+ENV PYTHON_BUILD_MIRROR_URL=https://mirrors.huaweicloud.com/python/
+# RUN pyenv install ${PYTHON_VERSION} &&  pyenv global ${PYTHON_VERSION}
+
+RUN pip install jupyter jupyterlab jupyter_contrib_nbextensions
+
+# install R
+RUN apt-get update && apt-get install -y \
+    r-base r-base-dev
+
+ENV CRAN_URL=https://cloud.r-project.org/
+ENV R_LIBS_USER=/workspaces/RStudio-container/tools/RPackages
+
+# install RStudio-server
+RUN apt install -y wget  \
+    && wget https://ppmb.lzu.edu.cn/files/rstudio-2024.04.2-764-amd64.deb  \
+    && apt-get install -y gdebi-core  \
+    && gdebi -n rstudio-2024.04.2-764-amd64.deb \
+    && rm rstudio-2024.04.2-764-amd64.deb
+
+
+# set user and pwd: rstudio/rstudio
+# RUN set -eo pipefail \
+#       && ln -s /dev/stdout /var/log/syslog \
+RUN useradd -m -d /home/rstudio rstudio \
+    && usermod -a -G root rstudio \
+    && echo rstudio:rstudio | chpasswd  \
+    && mkdir -p /home/rstudio/workspace \
+    && ln -s /workspace/RStudio-container /home/rstudio/workspace
+
+# RUN apt-get -y autoremove \
+#     && apt-get clean \
+#     && rm -rf /var/lib/apt/lists/*
+
+EXPOSE 8787
+
+
+# install ruby
+RUN apt-get update && apt-get install -y \
+    ruby-full rubygems ruby-dev
+
+# install rust
+ENV RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
+ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
+ENV RUSTUP_DIST_ROOT=https://mirrors.ustc.edu.cn/rust-static
+
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+ENV PATH="$HOME/.cargo/bin:$PATH"
+
+# # install .net core 6.0
+# RUN wget http://ftp.us.debian.org/debian/pool/main/i/icu/libicu67_67.1-1_amd64.deb && \
+# dpkg -i libicu67_67.1-1_amd64.deb
+# RUN wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
+#     dpkg -i packages-microsoft-prod.deb && \
+#     rm packages-microsoft-prod.deb && \
+#     apt-get update && \
+#     apt-get install -y apt-transport-https && \
+#     apt-get update && \
+#     apt-get install -y dotnet-sdk-6.0 dotnet-runtime-deps-6.0
+
+# install go1.21
+RUN wget https://go.dev/dl/go1.21.4.linux-amd64.tar.gz && \
+    tar -C /usr/local -xzf go1.21.4.linux-amd64.tar.gz && \
+    rm go1.21.4.linux-amd64.tar.gz
+ENV PATH=$PATH:/usr/local/go/bin
+ENV GOPROXY="https://goproxy.io,direct"
+
+# install nodejs20
+RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
+RUN apt-get install -y nodejs
+RUN echo '\n\
+    registry=http://registry.npm.taobao.org \n\
+    sass_binary_site=https://npmmirror.com/mirrors/node-sass/ \n\
+    electron_mirror=https://npmmirror.com/mirrors/electron/ \n\
+    ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ \n\
+    ' > ~/.npmrc
+RUN npm install -g yarn pnpm serve
+
+WORKDIR /workspaces
+
+RUN apt-get install -y openssh-server
+RUN apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+# 指定字符集支持命令行输入中文(根据需要选择字符集)
+ENV LANG C.UTF-8
+ENV LANGUAGE C.UTF-8
+
+# set path
+RUN echo '\n\
+    export JAVA_HOME=/root/.sdkman/candidates/java/17.0.11-ms \n\
+    export PATH=$PATH:$JAVA_HOME/bin \n\
+    export GRADLE_HOME=/opt/gradle/gradle-${GRADLE_VERSION} \n\
+    export PATH=$PATH:$GRADLE_HOME/bin \n\
+    export MAVEN_HOME=/opt/maven/apache-maven-${MAVEN_VERSION} \n\
+    export PATH=$PATH:$MAVEN_HOME/bin \n\
+    export FLUTTER_HOME=/opt/flutter \n\
+    export PUB_HOSTED_URL=https://pub.flutter-io.cn \n\
+    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn \n\
+    export PATH=$PATH:$FLUTTER_HOME/bin \n\
+    export PATH=$PATH:/opt/python/${PYTHON_VERSION}/bin \n\
+    export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1 \n\
+    export PYTHON_BUILD_MIRROR_URL=https://mirrors.huaweicloud.com/python/ \n\
+    export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static \n\
+    export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup \n\
+    export RUSTUP_DIST_ROOT=https://mirrors.ustc.edu.cn/rust-static \n\
+    export PATH=$PATH:/usr/local/go/bin \n\
+    export GOPROXY="https://goproxy.io,direct" \n\
+    ' >> ~/.bashrc
+
+# install vscode and extension
+RUN curl -fsSL https://code-server.dev/install.sh | sh &&\
+    code-server --install-extension redhat.vscode-yaml &&\
+    code-server --install-extension orta.vscode-jest &&\
+    code-server --install-extension dbaeumer.vscode-eslint &&\
+    code-server --install-extension ms-python.python &&\
+    code-server --install-extension ms-azuretools.vscode-docker &&\
+    code-server --install-extension mhutchie.git-graph &&\
+    code-server --install-extension ardisaurus.gitflow-actions-sidebar &&\
+    code-server --install-extension Dart-Code.flutter &&\
+    code-server --install-extension golang.go &&\
+    code-server --install-extension Vue.volar &&\
+    code-server --install-extension eamodio.gitlens &&\
+    code-server --install-extension REditorSupport.r &&\
+    code-server --install-extension vscjava.vscode-java-pack &&\
+    code-server --install-extension vscjava.vscode-java-debug &&\
+    code-server --install-extension vscjava.vscode-java-dependency &&\
+    code-server --install-extension vscjava.vscode-maven &&\
+    code-server --install-extension vscjava.vscode-spring-initializr &&\
+    echo done
+
+# install manual
+# docker run -it --rm -v /workspace:/workspaces sift-docker.pkg.coding.net/flutter-team/dev-container/dev-allinone:1.0.12-flutter /bin/bash
+COPY ms-python.vscode-pylance-2024.6.103.vsix .
+RUN code-server --install-extension ms-python.vscode-pylance-2024.6.103.vsix
+# code-server --install-extension ms-dotnettools.csharp &&\
+COPY ./frp /opt/frp
+
+VOLUME [ "/workspaces" ]
+
+CMD [ "/bin/bash" ]
+# ENTRYPOINT ["/usr/lib/rstudio-server/bin/rserver"]
+# CMD ["--server-daemonize=0", "--server-app-armor-enabled=0"]

+ 9 - 0
R/docker-compose.debug.yml

@@ -9,3 +9,12 @@ services:
       dockerfile: ./Dockerfile
     volumes:
       - ./:/app
+
+  rstudio:
+   container_name: rstudio
+   image: jianboy/rstudio:latest
+   build:
+     context: .
+     dockerfile: ./Dockerfile
+   volumes:
+     - ./:/app

+ 1 - 1
README.md

@@ -1,5 +1,5 @@
-
 # github-actions
+
 [![](https://img.shields.io/badge/Author-lyq-orange.svg)](https://git.yoqi.me/lyq)
 [![](https://img.shields.io/badge/version-1.3.1-brightgreen.svg)](https://git.yoqi.me/lyq/github-actions-creator)
 

+ 20 - 1
build.sh

@@ -9,10 +9,29 @@ source /etc/profile
 export JAVA_HOME=/usr/local/openjdk-11
 # export JAVA_HOME=/root/.sdkman/candidates/java/21.0.1-ms/
 # source "$HOME/.sdkman/bin/sdkman-init.sh"
-# sdk list
+# sdk list java
 # sdk install java 8.0.392-librca
+# sdk install java 11.0.24-librca
 # sdk default java 8.0.392-librca
 
+# docker
+# echo $DOCKER_HOST
+# unset DOCKER_HOST
+# sudo usermod -aG docker $USER
+
+# set gopath
+# export PATH=$PATH:$GOPATH/bin
+# mkdir /workspace/RStudio-container
+export PATH=$PATH:$(go env GOPATH)/bin
+
+# nodejs
+
+# rstudio
+# -e PASSWORD=rstudio
+# docker run --rm -ti -p 8787:8787 -e DISABLE_AUTH=true -e ROOT=true -v /workspace/aa:/workspace/aa  rocker/rstudio:4.4.1
+# docker run --rm -ti rocker/tidyverse R
+
+
 # flutter
 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

+ 7 - 0
docker/chrome/docker-compose.debug.yml

@@ -0,0 +1,7 @@
+version: '3.4'
+services:
+
+  chrome:
+    image: selenium/standalone-chrome
+    ports:
+      - 4444:4444

+ 8 - 0
docker/tomcat/Dockerfile

@@ -0,0 +1,8 @@
+#https://github.com/docker-library/tomcat
+#FROM tomcat:8.0-alpine
+
+FROM tomcat:latest
+
+ADD ./webapp /usr/local/tomcat/webapps/webapp
+
+CMD ["bash.sh", "run"]

+ 10 - 1
docs/dev/flutter.md

@@ -197,4 +197,13 @@ FROM gitpod/workspace-full-vnc
 
 ## circleci
 
-## bitrise
+## bitrise
+
+## Rstudio
+
+# -e PASSWORD=rstudio
+# docker run --rm -ti -p 8787:8787 -e DISABLE_AUTH=true -e ROOT=true -v /workspace/aa:/workspace/aa  rocker/rstudio:4.4.1
+
+# docker run --rm -ti rocker/tidyverse R
+
+

+ 16 - 0
docs/dev/php.md

@@ -17,6 +17,9 @@ docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianbo
 docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianboy/php8xc:latest /bin/bash
 
 composer install
+
+docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8112:8112 sineverba/php74xc:1.11.0 php -S 0.0.0.0:8112
+curl 127.0.0.1:8112
 ```
 
 php基础镜像:
@@ -110,6 +113,19 @@ docker run --rm -it -v /workspace:/app composer:latest /bin/bash
 composer create-project --prefer-dist yiisoft/yii2-app-basic demo
 ```
 
+### apidoc
+
+```
+docker run --rm -it -w /app -v ${PWD}:/app jujhars13/docker-node-apidocjs /bin/bash
+apidoc -i . -o doc
+
+docker run --rm \
+-v ${PWD}:/app \
+jujhars13/docker-node-apidocjs \
+apidoc -i api.superwidgets.com/ -o html/public -t template
+
+```
+
 ## 数据库
 
 通过docker快速启动一个测试数据库:

+ 1 - 1
docs/dev/python.md

@@ -3,7 +3,7 @@
 如项目需要在 python3.8 环境下开发,可以使用以下方式:
 
 ```
-docker run --rm -it -v /workspace:/app python:3.8 /bin/bash
+docker run --rm -it -v $(pwd):/app -w /app python:3.8 /bin/bash
 
 ```
 

+ 1 - 1
flutter/.devcontainer/3.7.7/devcontainer.json

@@ -3,7 +3,7 @@
 // https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/java-8
 {
 	"name": "Java 16",
-	"image": "jianboy/flutter-dev-container:3.13.5",
+	"image": "jianboy/flutter-dev-container:3.7.7",
 
 	"settings": {
 		"java.home": "/docker-java-home",

+ 19 - 6
flutter/docker-compose.debug.yml

@@ -1,9 +1,22 @@
 version: '3.4'
 
 services:
-  githubactionscreator:
-    image: openjdk:8-jdk-alpine
-    build:
-      context: .
-      dockerfile: ./Dockerfile
-    
+  flutter_dev:
+    container_name: flutter_dev
+    image: jianboy/flutter:latest
+    # build:
+    #   context: .
+    #   dockerfile: ./Dockerfile
+    ports:
+      - 8080:8080
+    working_dir: /app
+    volumes:
+      - ./:/app
+    networks:
+      - app-network
+    command: sh -c "flutter build apk --debug"
+  
+networks:
+  app-network:
+    driver: bridge
+  

+ 3 - 2
go/Dockerfile

@@ -40,6 +40,7 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories
     && apk del tzdata
 
 EXPOSE 8888
-VOLUME ["/app/config","/app/log"]
+VOLUME ["/app/config","/app/log", "/workspaces"]
 ENTRYPOINT ["./main"]
-CMD [ "/app/demo" ]
+# CMD [ "/app/demo" ]
+CMD [ "/bin/bash" ]

+ 0 - 11
go/Dockerfile-build

@@ -1,11 +0,0 @@
-# FROM golang:1.19 as builder
-FROM golang:1.20 as builder
-
-WORKDIR /workspaces
-
-ENV GOPROXY=https://goproxy.cn,direct
-
-VOLUME ['/workspaces']
-
-#ENTRYPOINT [ "/bin/sh" ]
-CMD [ "/bin/bash" ]

+ 10 - 11
nodejs/docker-compose.debug.yml

@@ -1,21 +1,14 @@
 version: '3'
 
 services:
-  node_container:
-    container_name: node_container
-    image: jianboy/node_container:latest
-    build:
-      context: .
-      dockerfile: ./Dockerfile-node
-    volumes:
-      - ./:/app
-      
   frontend:
-    image: node:20
+    # image: node:20
+    image: node:20-alpine
     container_name: dev-frontend
     build:
       context: ./frontend
       dockerfile: Dockerfile.dev
+    working_dir: /app
     volumes:
       - ./frontend/src:/app/src/
       - ./frontend/public:/app/public
@@ -25,4 +18,10 @@ services:
       - INFISICAL_TELEMETRY_ENABLED=${TELEMETRY_ENABLED}
     networks:
       - infisical-dev
-
+    command: sh -c "yarn install && yarn dev"
+    ports:
+      - 3000:3000
+  
+networks:
+  infisical-dev:
+    driver: bridge

+ 11 - 2
php/php8xc/Dockerfile

@@ -16,8 +16,8 @@ RUN apt-get update \
     && apt-get install -y mariadb-client \
     && docker-php-ext-install bcmath \
     && docker-php-ext-install ctype \
-    && docker-php-ext-configure gd \
-    && docker-php-ext-install gd mysqli zip pdo pdo_mysql exif pcntl bcmath opcache \
+    && docker-php-ext-configure gd --with-external-gd \
+    && docker-php-ext-install gd mysqli zip pdo pdo_mysql mbstring exif pcntl bcmath opcache \
     && docker-php-ext-enable mysqli pdo pdo_mysql exif pcntl bcmath gd
 
 RUN apt-get install --assume-yes --no-install-recommends --quiet \
@@ -38,6 +38,7 @@ RUN echo "extension=redis.so" > $PHP_INI_DIR/conf.d/redis.ini
 RUN pecl install xdebug-3.3.2 \
     && docker-php-ext-enable xdebug
 
+# install composer
 RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
 RUN php composer-setup.php
 RUN mv composer.phar /usr/local/bin/composer
@@ -50,7 +51,15 @@ RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/compos
 #     $PHP_INI_DIR/conf.d/
 WORKDIR /var/www/html
 
+#COPY composer.lock composer.json /var/www/
+
+RUN apt-get clean && rm -rf /var/lib/apt/lists/*
+
 EXPOSE 9000
+RUN groupadd -g 1000 www
+RUN useradd -u 1000 -ms /bin/bash -g www www
+#COPY --chown=www:www . /var/www
+USER www
 
 CMD service supervisor start \
     && php-fpm

+ 47 - 0
python/.github/workflows/cd.yml

@@ -0,0 +1,47 @@
+name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+
+on:
+  # release:
+  #   types: [published]
+  workflow_dispatch: ~
+  push:
+    branches: [master]
+    tags: [v*]
+
+jobs:
+  build-n-publish:
+    name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+    runs-on: ubuntu-latest
+    # permissions:
+    #   id-token: write
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.12'
+
+      - name: Install Dependencies
+        run: |
+          python -m pip install --upgrade pip wheel setuptools poetry
+          poetry config virtualenvs.in-project true
+          poetry install
+
+      - name: Build a binary wheel and a source tarball
+        run: |
+          poetry build
+
+      # - name: Publish distribution 📦 to Test PyPI
+      #   uses: pypa/gh-action-pypi-publish@release/v1
+      #   with:
+      #     repository_url: https://test.pypi.org/legacy/
+      #     packages_dir: dist/
+      #     password: ${{ secrets.PYPI_TOKEN }}
+
+      - name: Publish distribution 📦 to PyPI
+        if: startsWith(github.ref, 'refs/tags')
+        uses: pypa/gh-action-pypi-publish@release/v1
+        with:
+          packages_dir: dist/
+          password: ${{ secrets.PYPI_TOKEN }}

+ 110 - 0
python/.github/workflows/ci.yml

@@ -0,0 +1,110 @@
+name: ci
+
+on:
+  push:
+    branches: [main]
+    paths:
+      - 'mem0/**'
+      - 'tests/**'
+      - 'embedchain/**'
+      - 'embedchain/tests/**'
+      - 'embedchain/examples/**'
+  pull_request:
+    paths:
+      - 'mem0/**'
+      - 'tests/**'
+      - 'embedchain/**'
+      - 'embedchain/tests/**'
+      - 'embedchain/examples/**'
+
+jobs:
+  check_changes:
+    runs-on: ubuntu-latest
+    outputs:
+      mem0_changed: ${{ steps.filter.outputs.mem0 }}
+      embedchain_changed: ${{ steps.filter.outputs.embedchain }}
+    steps:
+    - uses: actions/checkout@v3
+    - uses: dorny/paths-filter@v2
+      id: filter
+      with:
+        filters: |
+          mem0:
+            - 'mem0/**'
+            - 'tests/**'
+          embedchain:
+            - 'embedchain/**'
+            - 'embedchain/tests/**'
+            - 'embedchain/examples/**'
+
+  build_mem0:
+    needs: check_changes
+    if: ${{ needs.check_changes.outputs.mem0_changed == 'true' || (needs.check_changes.outputs.mem0_changed == 'false' && needs.check_changes.outputs.embedchain_changed == 'false') }}
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.10", "3.11"]
+
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install poetry
+        uses: snok/install-poetry@v1
+        with:
+          version: 1.4.2
+          virtualenvs-create: true
+          virtualenvs-in-project: true
+      - name: Load cached venv
+        id: cached-poetry-dependencies
+        uses: actions/cache@v2
+        with:
+          path: .venv
+          key: venv-mem0-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
+      - name: Install dependencies
+        run: make install_all
+        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+      - name: Run tests and generate coverage report
+        run: make test
+
+  build_embedchain:
+    needs: check_changes
+    if: ${{ needs.check_changes.outputs.embedchain_changed == 'true' || (needs.check_changes.outputs.mem0_changed == 'false' && needs.check_changes.outputs.embedchain_changed == 'false') }}
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: ["3.9", "3.10", "3.11"]
+
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install poetry
+        uses: snok/install-poetry@v1
+        with:
+          version: 1.4.2
+          virtualenvs-create: true
+          virtualenvs-in-project: true
+      - name: Load cached venv
+        id: cached-poetry-dependencies
+        uses: actions/cache@v2
+        with:
+          path: .venv
+          key: venv-embedchain-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
+      - name: Install dependencies
+        run: cd embedchain && make install_all
+        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+      - name: Lint with ruff
+        run: cd embedchain && make lint
+      - name: Run tests and generate coverage report
+        run: cd embedchain && make coverage
+      - name: Upload coverage reports to Codecov
+        uses: codecov/codecov-action@v3
+        with:
+          file: coverage.xml
+        env:
+          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

+ 94 - 2
rust/Dockerfile

@@ -53,10 +53,102 @@ RUN mkdir .cargo && \
     chmod +x rustup-init && \
     ./rustup-init -y --default-toolchain ${RUST_VERSION} --target riscv64imac-unknown-none-elf && \
     rm rustup-init && \
-    source $HOME/.cargo/env && \
     cargo install cargo-binutils && \
     rustup component add llvm-tools-preview && \
     rustup component add rust-src
 
 EXPOSE 8080/tcp
-CMD ["code", "--auth", "none", "--bind-addr", "0.0.0.0:8080"]
+CMD ["code", "--auth", "none", "--bind-addr", "0.0.0.0:8080"]
+
+
+
+
+
+
+FROM ubuntu:22.04
+# SHELL ["/bin/bash", "-c"]
+
+LABEL email="liuyuqi<liuyuqi.gov@msn.cn>"
+ENV key=value
+WORKDIR /app
+
+# apt change to aliyun
+RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
+RUN sed -i s@/security.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
+
+RUN apt update && apt install -y curl wget
+
+# COPY .cargo/config ~/.cargo/config
+# COPY .cargo/credentials ~/.cargo/credentials
+
+# install nodejs
+RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash
+RUN apt install -y nodejs
+RUN echo '\n\
+    registry=http://registry.npm.taobao.org \n\
+    sass_binary_site=https://npmmirror.com/mirrors/node-sass/ \n\
+    electron_mirror=https://npmmirror.com/mirrors/electron/ \n\
+    ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ \n\
+    ' > ~/.npmrc
+RUN npm install -g yarn pnpm serve
+
+# install rust
+# 安装必要依赖与开发工具
+RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && \
+    apt-get update && apt-get install -y \
+    gcc-riscv64-unknown-elf gdb-multiarch dosfstools cmake \
+    git wget python3 vim file curl \
+    autoconf automake autotools-dev  libmpc-dev libmpfr-dev libgmp-dev \
+    gawk build-essential bison flex texinfo gperf libtool patchutils bc \
+    zlib1g-dev libexpat-dev \
+    ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
+# && rm -rf /var/lib/apt/lists/*
+
+#tauri deps
+RUN apt install -y libwebkit2gtk-4.0-dev \
+    libssl-dev \
+    libgtk-3-dev \
+    libayatana-appindicator3-dev \
+    librsvg2-dev
+
+# 安装 QEMU
+ARG QEMU_VERSION=7.0.0
+RUN cd /tmp && \
+    wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
+    tar xf qemu-${QEMU_VERSION}.tar.xz && \
+    cd qemu-${QEMU_VERSION} && \
+    ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
+    make -j && \
+    make install && \
+    cd .. && \
+    rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
+
+ARG RUST_VERSION=nightly
+ENV RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
+ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
+
+RUN mkdir -p ~/.cargo && \
+    echo '[source.crates-io]' >> ~/.cargo/config && \
+    echo 'replace-with = "aliyun"' >> ~/.cargo/config && \
+    echo '[source.aliyun]' >> ~/.cargo/config && \
+    echo 'registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"' >> ~/.cargo/config && \
+    echo '[source.ustc]' >> ~/.cargo/config && \
+    echo 'registry = "https://mirrors.ustc.edu.cn/crates.io-index"' >> ~/.cargo/config && \
+    echo '[source.sjtu]' >> ~/.cargo/config && \
+    echo 'registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"' >> ~/.cargo/config && \
+    echo '[source.tuna]' >> ~/.cargo/config && \
+    echo 'registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"' >> ~/.cargo/config && \
+    echo '[source.rustcc]' >> ~/.cargo/config && \
+    echo 'registry = "https://code.aliyun.com/rustcc/crates.io-index.git"' >> ~/.cargo/config
+
+# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable && \
+#     cargo install cargo-binutils && \
+#     rustup component add llvm-tools-preview && \
+#     rustup component add rust-src
+
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh &&\
+    sh rustup.sh -y --profile minimal &&\
+    PATH=$PATH:/root/.cargo/bin &&\
+    rustup target add riscv32i-unknown-none-elf &&\
+    rustup component add llvm-tools-preview
+