mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
fix build.yml (x10)
This commit is contained in:
parent
a65772f575
commit
3c5ce73734
38
.github/workflows/build.yml
vendored
38
.github/workflows/build.yml
vendored
@ -14,25 +14,39 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up JDK 22
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: 'oracle'
|
||||||
|
java-version: '22'
|
||||||
|
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Set datetime variable
|
|
||||||
id: vars
|
|
||||||
run: echo "DATETIME=$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Create multi-platform image
|
- name: Set datetime variable
|
||||||
run: |
|
id: vars
|
||||||
docker buildx create --use
|
run: echo "DATETIME=$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
|
||||||
docker buildx build --platform linux/amd64,linux/arm64 \
|
|
||||||
--tag dalbodeule/chzzkbot:${{ env.DATETIME }} \
|
- name: Build and push Docker image
|
||||||
--tag dalbodeule/chzzkbot:latest \
|
uses: docker/build-push-action@v2
|
||||||
--push .
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ secrets.DOCKER_USERNAME }}/chzzkbot:${{ env.DATETIME }}
|
||||||
|
${{ secrets.DOCKER_USERNAME }}/chzzkbot:latest
|
49
Dockerfile
49
Dockerfile
@ -1,42 +1,27 @@
|
|||||||
# Builder Stage
|
# Stage 1: Build the executable with GraalVM
|
||||||
FROM ghcr.io/graalvm/graalvm-ce:22.3.3 AS builder
|
FROM ghcr.io/graalvm/graalvm-ce:22.1.0 as build
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy Gradle wrapper and build scripts
|
# Install required dependencies
|
||||||
COPY gradlew ./
|
RUN gu install native-image
|
||||||
COPY gradle ./gradle
|
|
||||||
COPY build.gradle.kts .
|
|
||||||
COPY settings.gradle.kts .
|
|
||||||
COPY gradle.properties .
|
|
||||||
|
|
||||||
# Download dependencies
|
# Copy the Gradle files and source code
|
||||||
RUN ./gradlew --no-daemon dependencies
|
COPY build.gradle.kts settings.gradle.kts gradlew ./
|
||||||
|
COPY gradle gradle
|
||||||
|
COPY src src
|
||||||
|
|
||||||
# Copy the source code
|
# Build the project
|
||||||
COPY src ./src
|
RUN ./gradlew build
|
||||||
|
RUN ./gradlew nativeImage
|
||||||
|
|
||||||
# Build the application
|
# Stage 2: Create a minimal Docker image and add the binary
|
||||||
RUN ./gradlew nativeCompile
|
FROM alpine:3.13
|
||||||
|
|
||||||
# Runner Stage
|
|
||||||
FROM woahbase/alpine-glibc:latest AS runner
|
|
||||||
|
|
||||||
# Install glibc (required for running Java applications on Alpine)
|
|
||||||
RUN apk add --no-cache libc6-compat patchelf
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the native image from the builder stage
|
# Copy the executable from the build stage
|
||||||
COPY --from=builder /app/build/native/nativeCompile/chzzk_bot .
|
COPY --from=build /app/build/native-image/chzzk_bot .
|
||||||
|
|
||||||
# Ensure the application binary is executable
|
# Set the entry point
|
||||||
RUN chmod +x /app/chzzk_bot
|
ENTRYPOINT ["./chzzk_bot"]
|
||||||
|
|
||||||
# Patch the binary to use the correct dynamic linker
|
|
||||||
RUN patchelf --set-interpreter /lib/ld-linux-x86-64.so.2 /app/chzzk_bot
|
|
||||||
|
|
||||||
# Run the application
|
|
||||||
CMD ["./chzzk_bot"]
|
|
Loading…
x
Reference in New Issue
Block a user