diff --git a/.github/workflows/docker-image-amd64.yml b/.github/workflows/docker-image-amd64.yml deleted file mode 100644 index 05d2cc8..0000000 --- a/.github/workflows/docker-image-amd64.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Build and Push Docker Image -Amd64 - -on: - release: - types: [ created ] - workflow_dispatch: - inputs: - tag: - description: 'Tag Name' - required: true - - -jobs: - build-and-push: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Set tag name - id: tag_name - run: | - if [ "${{ github.event_name }}" = "release" ]; then - echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" - elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "::set-output name=tag::${{ github.event.inputs.tag }}" - fi - - - name: Build and push Docker image with Release tag - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfiles/Dockerfile - push: true - tags: | - yangclivia/gpt4-copilot-java:${{ steps.tag_name.outputs.tag }}-amd64 - platforms: linux/amd64 diff --git a/.github/workflows/docker-image-arm64.yml b/.github/workflows/docker-image-arm64.yml deleted file mode 100644 index 79509dc..0000000 --- a/.github/workflows/docker-image-arm64.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Build and Push Docker Image -Arm64 - -on: - release: - types: [ created ] - workflow_dispatch: - inputs: - tag: - description: 'Tag Name' - required: true - - -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Set tag name - id: tag_name - run: | - if [ "${{ github.event_name }}" = "release" ]; then - echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" - elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - echo "::set-output name=tag::${{ github.event.inputs.tag }}" - fi - - - name: Build and push Docker image with Release tag - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfiles/Dockerfile - push: true - tags: | - yangclivia/gpt4-copilot-java:${{ steps.tag_name.outputs.tag }}-arm64 - platforms: linux/arm64 diff --git a/.github/workflows/jar-image.yml b/.github/workflows/jar-image.yml new file mode 100644 index 0000000..bb92067 --- /dev/null +++ b/.github/workflows/jar-image.yml @@ -0,0 +1,46 @@ +name: Build and Push Docker Image -jar + +on: + release: + types: [created] + workflow_dispatch: + inputs: + tag: + description: 'Tag Name' + required: true + + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Set tag name + id: tag_name + run: | + if [ "${{ github.event_name }}" = "release" ]; then + echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" + elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "::set-output name=tag::${{ github.event.inputs.tag }}" + fi + + - name: Build and push Docker image with Release tag + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile/Dockerfile.jar + push: true + tags: | + yangclivia/gpt4-copilot-java:${{ steps.tag_name.outputs.tag }}-jar + platforms: linux/amd64,linux/arm64 + build-args: TARGETPLATFORM=${{ matrix.platform }} diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml deleted file mode 100644 index 932418e..0000000 --- a/.github/workflows/maven-publish.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Maven Package - -on: - release: - types: [ created ] - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v3 - - - name: Set up GraalVM - uses: DeLaGuardo/setup-graalvm@5.0 - with: - graalvm-version: '21.3' # 更新为支持 Java 17 的 GraalVM 版本 - java-version: 'java17' # 确保 Java 版本符合你的需求 - - - - name: Grant execute permission for mvnw - run: chmod +x ./mvnw - - - name: Set JAVA_HOME - run: echo "JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' | awk '{print \\\$3}')" >> $GITHUB_ENV - - - name: Build with Maven - run: ./mvnw native:compile -Pnative - - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -Pnative -s $GITHUB_WORKSPACE/settings.xml - env: - GITHUB_TOKEN: ${{ github.token }} - - diff --git a/.github/workflows/docker-image.yml b/.github/workflows/native-image.yml similarity index 93% rename from .github/workflows/docker-image.yml rename to .github/workflows/native-image.yml index 3ad1d46..2a1b2df 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/native-image.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image +name: Build and Push Docker Image -native on: release: @@ -38,7 +38,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./Dockerfiles/Dockerfile + file: ./Dockerfiles/Dockerfile.native push: true tags: | yangclivia/gpt4-copilot-java:${{ steps.tag_name.outputs.tag }} diff --git a/Dockerfiles/Dockerfile b/Dockerfiles/Dockerfile deleted file mode 100644 index 18e1c8b..0000000 --- a/Dockerfiles/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# Using Oracle GraalVM for JDK 17 -FROM devatherock/graalvm:21-ol8 AS builder - -# Set the working directory to /home/app -WORKDIR /build - -# Copy the source code into the image for building -COPY . /build - -# Add execute permission to mvnw script -RUN chmod +x mvnw - -# Build -RUN ./mvnw --no-transfer-progress native:compile -Pnative - -# Use a lightweight Linux base image with just enough runtime dependencies -FROM container-registry.oracle.com/os/oraclelinux:8-slim - -# Expose port 8080 for the application -EXPOSE 8080 - -# Copy the native executable into the containers -COPY --from=builder /build/target/gpt-4-copilot app - -ENTRYPOINT ["/app"] diff --git a/Dockerfiles/Dockerfile.jar b/Dockerfiles/Dockerfile.jar new file mode 100644 index 0000000..8bb7243 --- /dev/null +++ b/Dockerfiles/Dockerfile.jar @@ -0,0 +1,20 @@ +# 从 sapmachine:17.0.10-jre-ubuntu-jammy 镜像开始构建 +FROM sapmachine:17.0.10-jre-ubuntu-jammy + +# 指定维护者的名字 +LABEL maintainer="Yanyutin753" + +# 切换到 root 用户 +USER root + +# 复制JAR文件到容器的/app目录下 +COPY /target/gpt-4-copilot-0.0.4.jar /app/app.jar + +# 切换到/app目录 +WORKDIR /app + +# 声明服务运行在8081端口 +EXPOSE 8081 + +# 指定docker容器启动时运行jar包,适当减少JVM内存分配 +ENTRYPOINT exec java $JAVA_OPTS -Dfile.encoding=UTF-8 -jar app.jar $@ diff --git a/Dockerfiles/Dockerfile.jvm b/Dockerfiles/Dockerfile.jvm deleted file mode 100644 index b8aa9c6..0000000 --- a/Dockerfiles/Dockerfile.jvm +++ /dev/null @@ -1,13 +0,0 @@ -# 基于Java 17的GraalVM构建镜像 -FROM container-registry.oracle.com/graalvm/native-image:21-ol8 AS builder -WORKDIR /app -COPY . /app - -# 安装native-image工具 -RUN gu install native-image - -# 使用Maven构建应用程序 -RUN mvn package -DskipTests - -# 使用native-image编译成本地二进制文件 -RUN native-image -cp target/benchmark-jibber-0.0.1-SNAPSHOT.jar diff --git a/Dockerfiles/Dockerfile.native b/Dockerfiles/Dockerfile.native index a613a32..c15b345 100644 --- a/Dockerfiles/Dockerfile.native +++ b/Dockerfiles/Dockerfile.native @@ -1,7 +1,26 @@ -FROM container-registry.oracle.com/os/oraclelinux:8-slim +# Using devatherock/graalvm for JDK 17 +FROM devatherock/graalvm:21-ol8 AS builder -ARG APP_FILE -EXPOSE 8080 +# Set the working directory to /home/app +WORKDIR /build + +# Copy the source code into the image for building +COPY . /build + +# Build +RUN chmod +x mvnw && \ + ./mvnw --no-transfer-progress native:compile -Pnative && \ + rm -rf /root/.m2 + +# Use a lightweight Linux base image with just enough runtime dependencies +FROM photon:latest + +# Set the timezone +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Copy the native executable into the containers +COPY --from=builder /build/target/gpt-4-copilot gpt-4-copilot + +ENTRYPOINT ["/gpt-4-copilot"] -COPY target/${APP_FILE} app -ENTRYPOINT ["/app"] \ No newline at end of file diff --git a/config.json b/config.json index e6d0527..facf883 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,6 @@ "prefix": "", "vscode_version": "vscode\/1.85.2", "serverPort": 8081, - "maxPoolSize": 250, + "maxPoolSize": 300, "gpt4_sleepTime": 110 -} \ No newline at end of file +}