diff --git a/.github/workflows/build-nvidia.yml b/.github/workflows/build-nvidia.yml deleted file mode 100644 index efc5dcbe..00000000 --- a/.github/workflows/build-nvidia.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build jmalcloud-nvidia Docker Image - -on: - workflow_dispatch: - release: - types: [published] - tags: [v*] - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 17 and Maven 3.8.4 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - maven-version: '3.8.4' - - - name: Build with Maven - run: mvn clean package -DskipTests - - - name: Extract project version from pom.xml - run: | - VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) - echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: docker/jmalcloud-nvidia/Dockerfile - push: true - tags: jmal/jmalcloud-nvidia:${{ env.PROJECT_VERSION }},jmal/jmalcloud-nvidia:latest - platforms: linux/amd64,linux/arm64 - build-args: | - VERSION=${{ env.PROJECT_VERSION }} - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/build_jdk17_ffmpeg_nvidia.yml b/.github/workflows/build_jdk17_ffmpeg_nvidia.yml deleted file mode 100644 index c7d1bac8..00000000 --- a/.github/workflows/build_jdk17_ffmpeg_nvidia.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build jdk17_ffmpeg_nvidia - -on: - workflow_dispatch: - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 17 and Maven 3.8.4 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - maven-version: '3.8.4' - - - name: Build with Maven - run: mvn clean package -DskipTests - - - name: Extract project version from pom.xml - run: | - VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) - echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: docker/nvidia/Dockerfile - push: true - tags: jmal/jdk17_ffmpeg_nvidia:latest - platforms: linux/amd64,linux/arm64 - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/build_jdk_ffmpeg.yml b/.github/workflows/build_jdk_ffmpeg.yml index 4a12bd16..82dd0f94 100644 --- a/.github/workflows/build_jdk_ffmpeg.yml +++ b/.github/workflows/build_jdk_ffmpeg.yml @@ -1,4 +1,4 @@ -name: Build jdk17_ffmpeg +name: Build jdk17_ffmpeg_nvidia on: workflow_dispatch: @@ -41,7 +41,10 @@ jobs: context: . file: docker/Dockerfile push: true - tags: jmal/jdk17_ffmpeg:latest + tags: jmal/jdk17_ffmpeg_nvidia:latest platforms: linux/amd64,linux/arm64 - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + build-args: | + ARCH=${{ matrix.arch }} + strategy: + matrix: + arch: [amd64, arm64] diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 4985c63e..89cdba41 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -1,4 +1,4 @@ -name: Build test +name: Build test (nvidia) on: push: @@ -52,8 +52,8 @@ jobs: file: ./Dockerfile push: true tags: | - jmal/jmalcloud:test - ghcr.io/${{ secrets.GHCR_IO_USERNAME }}/jmalcloud:test + jmal/jmalcloud-nvidia:test + ghcr.io/${{ secrets.GHCR_IO_USERNAME }}/jmalcloud-nvidia:test platforms: linux/amd64,linux/arm64 build-args: | VERSION=${{ env.PROJECT_VERSION }} diff --git a/.github/workflows/test-nvidia-build.yml b/.github/workflows/test-nvidia-build.yml deleted file mode 100644 index 39798ea6..00000000 --- a/.github/workflows/test-nvidia-build.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Build test (nvidia) - -on: - push: - branches: - - 'master' - workflow_dispatch: - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 17 and Maven 3.8.4 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - maven-version: '3.8.4' - - - name: Build with Maven - run: mvn clean package -DskipTests - - - name: Extract project version from pom.xml - run: | - VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) - echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ secrets.GHCR_IO_USERNAME }} - password: ${{ secrets.GHCR_IO_TOKEN }} - - - name: Build and push Docker image to multiple registries - uses: docker/build-push-action@v2 - with: - context: . - file: docker/jmalcloud-nvidia/Dockerfile - push: true - tags: | - jmal/jmalcloud-nvidia:test - ghcr.io/${{ secrets.GHCR_IO_USERNAME }}/jmalcloud-nvidia:test - platforms: linux/amd64,linux/arm64 - build-args: | - VERSION=${{ env.PROJECT_VERSION }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 7be0a616..33898c4d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,15 +1,43 @@ -FROM eclipse-temurin:17-jre +FROM nvidia/cuda:11.7.1-base-ubuntu22.04 AS base -# 安装 ffmpeg 和 tesseract -RUN apt-get update && \ - apt-get install -y ffmpeg libavcodec-extra locales tesseract-ocr && \ - locale-gen en_US.UTF-8 && \ - update-locale LANG=en_US.UTF-8 +# 设置非交互式安装,避免 tzdata 等包的配置暂停 +ENV DEBIAN_FRONTEND=noninteractive -# 设置环境变量 +# 安装wget 和 tesseract +RUN apt-get update && apt-get install -y wget && apt-get install -y locales tesseract-ocr && \ + locale-gen en_US.UTF-8 && \ + update-locale LANG=en_US.UTF-8 + +ARG ARCH=amd64 + +# 下载jellyfin-ffmpeg.deb +RUN wget https://repo.jellyfin.org/files/ffmpeg/ubuntu/latest-5.x/${ARCH}/jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb + +# 安装下载的 jellyfin-ffmpeg.deb +RUN dpkg -i jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb || apt-get install -fy + +# 卸载 wget 并清理 +RUN apt-get remove -y wget && apt-get clean && rm -rf /var/lib/apt/lists/* + +# 清除安装文件 +RUN rm -rf jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb + +# 将/usr/lib/jellyfin-ffmpeg添加到PATH +ENV PATH=/usr/lib/jellyfin-ffmpeg:$PATH + +# 环境变量 ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ - LC_ALL=en_US.UTF-8 + LC_ALL=en_US.UTF-8 \ + LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \ + NVIDIA_DRIVER_CAPABILITIES=compute,utility,video \ + NVIDIA_VISIBLE_DEVICES=all + +FROM eclipse-temurin:17-jre AS java-base + +# 合并 CUDA 和 Java 环境 +FROM base AS final +COPY --from=java-base /opt/java/openjdk /opt/java/openjdk # 设置时区 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime @@ -20,4 +48,10 @@ ADD docker/ip2region.xdb /jmalcloud/ ADD tess4j/datapath/chi_sim.traineddata /jmalcloud/tess4j/datapath/ + ADD target/lib /usr/local/clouddisk-lib + +# 更新 PATH 和 LD_LIBRARY_PATH +ENV PATH="/opt/java/openjdk/bin:${PATH}" + +CMD ["bash"] diff --git a/docker/jmalcloud-nvidia/Dockerfile b/docker/jmalcloud-nvidia/Dockerfile deleted file mode 100644 index 89ad380a..00000000 --- a/docker/jmalcloud-nvidia/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM jmal/jdk17_ffmpeg_nvidia:latest - -ARG VERSION - -ENV MONGODB_URI "mongodb://mongo:27017/jmalcloud" -ENV RUN_ENVIRONMENT prod -ENV JVM_OPTS "-Xms50m -Xmx512m" -ENV LOG_LEVEL warn - -ENV FILE_MONITOR true -ENV FILE_ROOT_DIR /jmalcloud/files -ENV TESS4J_DATA_PATH /jmalcloud/tess4j/datapath - -ADD target/clouddisk-${VERSION}.jar /usr/local/ - -VOLUME /jmalcloud/ - -# 设置支持的平台 -ARG TARGETPLATFORM -RUN echo "Building for platform: $TARGETPLATFORM" -LABEL org.label-schema.build.multi-platform=true -ENV PLATFORM=$TARGETPLATFORM -ENV VERSION=${VERSION} - -# 将 Linux/arm64/v8 架构设置为默认平台 -# 如果需要,可以根据需要更改此设置 -ENV DOCKER_DEFAULT_PLATFORM=linux/amd64,linux/arm64 - -EXPOSE 8088 - -CMD java -Dfile.encoding=UTF-8 -Dloader.path=/usr/local/clouddisk-lib -jar ${JVM_OPTS} /usr/local/clouddisk-${VERSION}.jar --spring.profiles.active=${RUN_ENVIRONMENT} --spring.data.mongodb.uri=${MONGODB_URI} --tess4j.data-path=${TESS4J_DATA_PATH} --file.monitor=${FILE_MONITOR} --file.rootDir=${FILE_ROOT_DIR} --logging.level.root=${LOG_LEVEL} --file.ip2region-db-path=/jmalcloud/ip2region.xdb diff --git a/docker/nvidia/Dockerfile b/docker/nvidia/Dockerfile deleted file mode 100644 index 33898c4d..00000000 --- a/docker/nvidia/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM nvidia/cuda:11.7.1-base-ubuntu22.04 AS base - -# 设置非交互式安装,避免 tzdata 等包的配置暂停 -ENV DEBIAN_FRONTEND=noninteractive - -# 安装wget 和 tesseract -RUN apt-get update && apt-get install -y wget && apt-get install -y locales tesseract-ocr && \ - locale-gen en_US.UTF-8 && \ - update-locale LANG=en_US.UTF-8 - -ARG ARCH=amd64 - -# 下载jellyfin-ffmpeg.deb -RUN wget https://repo.jellyfin.org/files/ffmpeg/ubuntu/latest-5.x/${ARCH}/jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb - -# 安装下载的 jellyfin-ffmpeg.deb -RUN dpkg -i jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb || apt-get install -fy - -# 卸载 wget 并清理 -RUN apt-get remove -y wget && apt-get clean && rm -rf /var/lib/apt/lists/* - -# 清除安装文件 -RUN rm -rf jellyfin-ffmpeg5_5.1.4-3-jammy_${ARCH}.deb - -# 将/usr/lib/jellyfin-ffmpeg添加到PATH -ENV PATH=/usr/lib/jellyfin-ffmpeg:$PATH - -# 环境变量 -ENV LANG=en_US.UTF-8 \ - LANGUAGE=en_US:en \ - LC_ALL=en_US.UTF-8 \ - LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \ - NVIDIA_DRIVER_CAPABILITIES=compute,utility,video \ - NVIDIA_VISIBLE_DEVICES=all - -FROM eclipse-temurin:17-jre AS java-base - -# 合并 CUDA 和 Java 环境 -FROM base AS final -COPY --from=java-base /opt/java/openjdk /opt/java/openjdk - -# 设置时区 -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime - -RUN mkdir -p /jmalcloud/files /jmalcloud/tess4j/datapath - -ADD docker/ip2region.xdb /jmalcloud/ - -ADD tess4j/datapath/chi_sim.traineddata /jmalcloud/tess4j/datapath/ - - -ADD target/lib /usr/local/clouddisk-lib - -# 更新 PATH 和 LD_LIBRARY_PATH -ENV PATH="/opt/java/openjdk/bin:${PATH}" - -CMD ["bash"]