From f4bd9e95cc6c8b15f741ea817e70c43889aefc62 Mon Sep 17 00:00:00 2001 From: noeppi_noeppi Date: Sat, 29 Jun 2024 22:56:13 +0200 Subject: [PATCH] Build and publish docker images. --- .github/workflows/publish.yml | 18 ++++++++++++++++++ Dockerfile | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0fa542a..3ff3879 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,14 @@ jobs: with: distribution: 'temurin' java-version: '21' + - name: 'Build Docker Image' + run: | + docker build \ + --pull --no-cache \ + --build-arg="VERSION=${{ github.ref_name }}" \ + -t "ghcr.io/moddingx/modbadges:${{ github.ref_name }}" \ + -t "ghcr.io/moddingx/modbadges:latest" \ + . - name: 'Build' run: | ./gradlew \ @@ -23,3 +31,13 @@ jobs: -PmoddingxUsername=${{ secrets.PUBLISH_USER }} \ -PmoddingxPassword=${{ secrets.PUBLISH_PASSWORD }} \ build publish + - name: 'Login to package registry' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: 'Publish Docker Image' + run: | + docker push "ghcr.io/moddingx/modbadges:${{ github.ref_name }}" + docker push "ghcr.io/moddingx/modbadges:latest" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..971eb40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM gradle:8-jdk21 AS build +ARG VERSION +COPY . /data +WORKDIR /data +RUN gradle -Pversion="${VERSION}" --no-daemon clean build +WORKDIR /dist +RUN tar --strip-components=1 -xf "/data/build/distributions/ModBadges-${VERSION}.tar" + +FROM eclipse-temurin:21 +COPY --from=build --link /dist/ /data/ +ENV JAVA_OPTS="-server" +CMD [ "/data/bin/ModBadges", "--no-ssl", "--docker" ]