From 29469a01591c613944a384211b28b38d15bc3b6e Mon Sep 17 00:00:00 2001 From: YuCat <66810215+YuCat-OVO@users.noreply.github.com> Date: Sun, 5 May 2024 18:34:08 +0800 Subject: [PATCH] Test action --- .github/workflows/build.yml | 5 ++- .github/workflows/test.yml | 51 +++++++++++++++++++++++++ .github/workflows/version.yml | 44 --------------------- Dockerfile | 72 +++++++---------------------------- Dockerfile.arm64 | 53 ++++++++++++++++++++++++++ docker-bake.hcl | 25 ++++++++++++ docker.yml | 31 +++++++++++++++ 7 files changed, 177 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/version.yml create mode 100644 Dockerfile.arm64 create mode 100644 docker-bake.hcl create mode 100644 docker.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4a6ea6..dea5044 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,15 +5,16 @@ on: push: branches: - "main" + tags: + - "[0-9]+.[0-9]+.[0-9]+" paths-ignore: - ".github/**" - "docs/**" - "**.md" - - "get_version.py" env: IMAGE_NAME: baidunetdisk-docker - DOCKERHUB_SLUG: yucatovo/baidunetdisk-docker + DOCKERHUB_SLUG: docker.io/yucatovo/baidunetdisk-docker GHCR_SLUG: ghcr.io/yucat-ovo/baidunetdisk-docker jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e0efa57 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +name: test + +on: + workflow_dispatch: + push: + branches: + - "main" + - "develop" + tags: + - "[0-9]+.[0-9]+.[0-9]+" + paths-ignore: + - ".github/**" + - "docs/**" + - "**.md" +env: + BUILD_TAG: baidunetdisk-docker:test + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platforms: ["linux/amd64", "linux/arm64"] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set the value + id: set-vars + run: | + echo "TARGET=$(echo ${{ matrix.platforms }} | sed 's#/#-#g')" >> "$GITHUB_OUTPUT" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: ${{ matrix.platforms }} + + - name: Build + uses: docker/bake-action@v4 + with: + targets: ${{ steps.set-vars.outputs.TARGET }} + env: + DEFAULT_TAG: ${{ env.BUILD_TAG }} + + - name: Test + run: | + docker run -t --rm ${{ env.BUILD_TAG }} diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml deleted file mode 100644 index ac69818..0000000 --- a/.github/workflows/version.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Get BaiduNetdisk Version - -on: - workflow_dispatch: - schedule: - - cron: "0 3 * * 0" - push: - branches: - - "main" - paths: - - "get_version.py" - -jobs: - get-version: - name: Get BaiduNetdisk Version - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set variables - id: set-vars - run: | - RELEASE_NAME="Released on $(date +%Y%m%d%H%M)" - - echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_OUTPUT - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.11.7" - - - name: Run Script - run: | - pip install -r requirements.txt - python get_version.py - - - name: Git push assets to branch - run: | - git config --local user.name "github-actions[bot]" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add *.json - git commit -m "${{ steps.set-vars.outputs.RELEASE_NAME }}" || true - git push diff --git a/Dockerfile b/Dockerfile index 999f6b9..748845a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ # syntax=docker/dockerfile:1 +FROM docker.io/library/alpine:edge as download -FROM ghcr.io/linuxserver/baseimage-kasmvnc:debianbookworm +RUN \ + sed -i 's/dl-cdn.alpinelinux.org/mirrors.lzu.edu.cn/g' /etc/apk/repositories && \ + apk update && \ + apk add wget curl jq &&\ + wget $(curl 'https://yun.baidu.com/disk/cmsdata?platform=linux&page=1&num=1' | jq -r '.["list"][0]["url_1"]') -O /tmp/baidunetdisk.deb -# set version label -ARG BUILD_DATE -ARG VERSION -ARG TARGETPLATFORM -LABEL build_version="version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="YuCat-OVO" -LABEL org.opencontainers.image.source="https://github.com/linuxserver/docker-baseimage-kasmvnc" +FROM ghcr.io/linuxserver/baseimage-kasmvnc:debianbookworm-062d5346-ls56 + +LABEL org.opencontainers.image.source="https://github.com/YuCat-OVO/BaiduNetdisk-Docker" ENV \ CUSTOM_PORT="8080" \ @@ -16,67 +17,22 @@ ENV \ HOME="/config" \ TITLE="Baidunetdisk" -COPY url.json /tmp/ - +COPY --from=download /tmp/baidunetdisk.deb /tmp/baidunetdisk.deb # add local files COPY root/ / RUN \ - TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} && \ - echo "**** arch: ${TARGETPLATFORM} ****" && \ - echo "**** add icon ****" && \ - curl -o \ - /kclient/public/icon.png \ - https://raw.githubusercontent.com/YuCat-OVO/BaiduNetdisk-Docker/master/docs/baidunetdisk.png && \ + sed -i "s/deb.debian.org/mirror.bfsu.edu.cn/g" /etc/apt/sources.list &&\ + sed -i "s/security.debian.org/mirror.bfsu.edu.cn/g" /etc/apt/sources.list &&\ echo "**** fix trusted.gpg ****" && \ mv /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/docker.gpg && \ - echo "**** install runtime packages ****" && \ - if [ -n ${TZ} ]; then \ - echo "**** TZ not found, setting up ****" && \ - export TZ=Asia/Shanghai; \ - fi && \ - export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && \ + apt-get update -y && \ apt-get -yy -qq install --no-install-recommends --no-install-suggests --fix-missing \ - wget \ fonts-wqy-microhei \ fonts-wqy-zenhei \ - dbus \ - fcitx-rime \ - libnss3 \ - libopengl0 \ - libxkbcommon-x11-0 \ - libxcb-cursor0 \ - libxcb-icccm4 \ - libxcb-image0 \ - libxcb-keysyms1 \ - libxcb-randr0 \ - libxcb-render-util0 \ - libxcb-xinerama0 \ - libxdamage1 \ - poppler-utils \ - python3 \ - python3-xdg \ desktop-file-utils && \ + \ echo "**** install BaiduNetdisk ****" && \ - if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ - echo "**** ${TARGETPLATFORM}, reading from url.json ****"; \ - BAIDUNETDISK_VERSION=$(jq -r ".[-2]" /tmp/url.json); \ - BAIDUNETDISK_URL=$(jq -r ".[-2]" /tmp/url.json); \ - elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ - echo "**** ${TARGETPLATFORM}, reading from url.json ****"; \ - BAIDUNETDISK_VERSION=$(jq -r ".[-1]" /tmp/url.json); \ - BAIDUNETDISK_URL=$(jq -r ".[-1]" /tmp/url.json); \ - echo "**** ${TARGETPLATFORM}, add args ****" && \ - sed -i "s/baidunetdisk --no-sandbox/baidunetdisk --no-sandbox --disable-gpu-sandbox/g" /defaults/*; \ - else \ - echo "**** err, use default url ****" && \ - BAIDUNETDISK_URL="https://issuepcdn.baidupcs.com/issue/netdisk/LinuxGuanjia/4.17.7/baidunetdisk_4.17.7_amd64.deb"; \ - fi && \ - echo "***** Getting ${BAIDUNETDISK_URL} ****" && \ - curl -o \ - /tmp/baidunetdisk.deb -L \ - "$BAIDUNETDISK_URL" && \ for i in \ $(dpkg -I /tmp/baidunetdisk.deb | grep "Depends" | cut -c11- | awk -F ', ' '{ for(i=1; i<=NF; i++) print $i }'); \ do \ diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..68a2894 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,53 @@ +# syntax=docker/dockerfile:1 +FROM docker.io/library/alpine:edge as download + +RUN \ + sed -i 's/dl-cdn.alpinelinux.org/mirrors.lzu.edu.cn/g' /etc/apk/repositories && \ + apk update && \ + apk add wget curl jq &&\ + wget $(curl 'https://yun.baidu.com/disk/cmsdata?platform=linux&page=1&num=1' | jq -r '.["list"][0]["url_1"]' | sed "s/amd64/arm64/g") -O /tmp/baidunetdisk.deb + +FROM ghcr.io/linuxserver/baseimage-kasmvnc:debianbookworm-062d5346-ls56 + +LABEL org.opencontainers.image.source="https://github.com/YuCat-OVO/BaiduNetdisk-Docker" + +ENV \ + CUSTOM_PORT="8080" \ + CUSTOM_HTTPS_PORT="8181" \ + HOME="/config" \ + TITLE="Baidunetdisk" + +COPY --from=download /tmp/baidunetdisk.deb /tmp/baidunetdisk.deb +# add local files +COPY root/ / + +RUN \ + sed -i "s/deb.debian.org/mirror.bfsu.edu.cn/g" /etc/apt/sources.list &&\ + sed -i "s/security.debian.org/mirror.bfsu.edu.cn/g" /etc/apt/sources.list &&\ + echo "**** fix trusted.gpg ****" && \ + mv /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/docker.gpg && \ + apt-get update -y && \ + apt-get -yy -qq install --no-install-recommends --no-install-suggests --fix-missing \ + fonts-wqy-microhei \ + fonts-wqy-zenhei \ + desktop-file-utils && \ + \ + echo "**** install BaiduNetdisk ****" && \ + sed -i "s/baidunetdisk --no-sandbox/baidunetdisk --no-sandbox --disable-gpu-sandbox/g" /defaults/*; \ + for i in \ + $(dpkg -I /tmp/baidunetdisk.deb | grep "Depends" | cut -c11- | awk -F ', ' '{ for(i=1; i<=NF; i++) print $i }'); \ + do \ + if [ -n "$(dpkg -l | grep ^ii | grep $i)" ]; \ + then \ + echo "${i} installed,skip"; \ + else \ + apt-get -yy -qq install --no-install-recommends --no-install-suggests --fix-missing ${i}; \ + fi \ + done && \ + dpkg -i /tmp/baidunetdisk.deb && \ + echo "**** cleanup ****" && \ + apt-get clean && \ + rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..f6ca76d --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,25 @@ +variable "TAG" { + default = "baidunetdisk-docker:latest" +} + +group "linux-amd64" { + targets = ["image-amd64"] +} +group "linux-arm64" { + targets = ["image-arm64"] +} + +target "docker-metadata-action" { + tags = ["${TAG}"] +} + +target "image-amd64" { + platforms = ["linux/amd64"] + inherits = ["docker-metadata-action"] + dockerfile = "Dockerfile" +} +target "image-arm64" { + platforms = ["linux/arm64"] + inherits = ["docker-metadata-action"] + dockerfile = "Dockerfile.arm64" +} diff --git a/docker.yml b/docker.yml new file mode 100644 index 0000000..6c3f66c --- /dev/null +++ b/docker.yml @@ -0,0 +1,31 @@ +input: + job: + package-manager: docker + allowed-updates: + - update-type: all + source: + provider: github + repo: YuCat-OVO/BaiduNetdisk-Docker + directory: / + branch: develop + commit: 16164b19aa9c08da55b0bd26fb4b2228262d0eab +output: + - type: update_dependency_list + expect: + data: + dependencies: + - name: linuxserver/baseimage-kasmvnc + requirements: + - file: Dockerfile + groups: [] + requirement: null + source: + registry: ghcr.io + tag: debianbookworm + version: debianbookworm + dependency_files: + - /Dockerfile + - type: mark_as_processed + expect: + data: + base-commit-sha: 16164b19aa9c08da55b0bd26fb4b2228262d0eab