This commit is contained in:
Yanyutin753
2024-02-17 19:33:09 +08:00
10 changed files with 94 additions and 175 deletions

View File

@@ -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

View File

@@ -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

46
.github/workflows/jar-image.yml vendored Normal file
View File

@@ -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 }}

View File

@@ -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 }}

View File

@@ -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 }}

View File

@@ -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"]

View File

@@ -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 $@

View File

@@ -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

View File

@@ -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"]

View File

@@ -5,6 +5,6 @@
"prefix": "",
"vscode_version": "vscode\/1.85.2",
"serverPort": 8081,
"maxPoolSize": 250,
"maxPoolSize": 300,
"gpt4_sleepTime": 110
}
}