From 23b94c58eea53af4679590e3e5366a929e78247a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B1=BC=E9=A6=99ROS?= <87068644+fishros@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:49:58 +0800 Subject: [PATCH] feat: add release for docker --- .github/workflows/build_release.yml | 34 +++++++++++++++++++++++++++++ .gitignore | 3 ++- Dockerfile | 20 ++++------------- Dockerfile.build | 21 ------------------ Dockerfile.build.win | 8 ------- tool/network.py | 2 +- 6 files changed, 41 insertions(+), 47 deletions(-) delete mode 100644 Dockerfile.build delete mode 100644 Dockerfile.build.win diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index e6541a8..7c24d81 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -27,6 +27,16 @@ jobs: name: build-artifacts path: dist + - name: Copy Bin For Docker + run: mkdir dist-for-docker && cp $(ls -1 dist/*) dist-for-docker/fishbot_tool_linux_amd64 + + - name: Archive build artifacts + uses: actions/upload-artifact@v2 + with: + name: build-artifacts-for-docker + path: dist-for-docker + + build-windows: runs-on: windows-latest steps: @@ -87,3 +97,27 @@ jobs: prerelease: false files: | dist/* + + release-docker: + runs-on: ubuntu-latest + steps: + - name: Docker login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download built artifacts + uses: actions/download-artifact@v2 + with: + name: build-artifacts-for-docker + path: ./dist-for-docker + + - name: Build the Docker image + run: docker build -f Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/fishbot_tool:${{ env.REF_NAME }} . + + - name: Docker image push + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/fishbot_tool:${{ env.REF_NAME }} diff --git a/.gitignore b/.gitignore index c6bdb6b..ab2ea69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ build/ dist/ -*.bin \ No newline at end of file +*.bin +dist-for-docker/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 464e9a1..6bb8f46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,14 @@ FROM ubuntu:jammy -RUN echo "chooses:\n" > fish_install.yaml \ - && echo "- {choose: 5, desc: '一键安装:ROS(支持ROS和ROS2,树莓派Jetson)'}\n" >> fish_install.yaml \ - && echo "- {choose: 2, desc: 更换源继续安装}\n" >> fish_install.yaml \ - && echo "- {choose: 1, desc: 清理三方源}\n" >> fish_install.yaml \ - && apt update && apt install wget python3 python3-distro python3-yaml -y \ - && wget http://fishros.com/install -O fishros && /bin/bash fishros \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && apt-get clean && apt autoclean \ - && rm -rf fish_install.yaml - -# RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata - - RUN apt-get update && apt-get install -y \ + wget \ fonts-wqy-zenhei \ libgl1 \ libegl1 \ && apt-get clean && apt-get autoclean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -COPY "dist/f1.alpha_linux_x64" /fishbot -RUN chmod +x /fishbot -ENTRYPOINT ["/fishbot"] +COPY "dist-for-docker/fishbot_tool_linux_amd64" /fishbot_tool +RUN chmod +x /fishbot_tool +ENTRYPOINT ["/fishbot_tool"] # docker run -it --rm --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY fishbot-tool \ No newline at end of file diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index 2a5ef66..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,21 +0,0 @@ -FROM ubuntu:22.04 - -RUN apt update && apt install python3 python3-pip libglib2.0-dev -y - -RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \ - && pip3 install esptool pyserial pyqt6 requests pyinstaller - -RUN apt install ffmpeg libsm6 libxext6 libgl1 libegl1 \ - libxcb-xinerama0 libxcb-xinerama0-dev libxcb-util1 \ - '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev \ - libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev \ - language-pack-zh-hans fonts-noto-cjk libqt6* -y - -ENV LANG zh_CN.UTF-8 -ENTRYPOINT [] - -# docker build -t fishros2/fishbot_tool:build_ubuntu22 -f Dockerfile.build . -# docker push fishros2/fishbot_tool:build_ubuntu22 -# docker run -it --rm --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY fishros2/fishbot-tool python main.py - - diff --git a/Dockerfile.build.win b/Dockerfile.build.win deleted file mode 100644 index 658e0e2..0000000 --- a/Dockerfile.build.win +++ /dev/null @@ -1,8 +0,0 @@ -FROM docker.io/batonogov/pyinstaller-windows - -SHELL ["cmd", "/S", "/C"] - -RUN apt install wget && wget https://github.com/espressif/esptool/releases/download/v4.7.0/esptool-v4.7.0-win64.zip - -# docker build -t fishros2/fishbot_tool:build_win11 -f Dockerfile.build.win . -# docker run --rm -it fishros2/fishbot_tool:build_win11 /bin/bash diff --git a/tool/network.py b/tool/network.py index 1de226e..ec89ad3 100644 --- a/tool/network.py +++ b/tool/network.py @@ -11,10 +11,10 @@ def get_version_data(self): """ 获取版本数据信息 """ + configs = [] try: response = requests.get(self.version_info_url) raw_data = response.text - configs = [] start = raw_data.find("```json")+7 end = raw_data.find('```', start) while start != -1 and end != -1: