Skip to content

Commit a06aa14

Browse files
committed
Java 21, create docker image
1 parent 86931fd commit a06aa14

File tree

9 files changed

+255
-131
lines changed

9 files changed

+255
-131
lines changed

.github/workflows/gradle.yml renamed to .github/workflows/build.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# This workflow will build a Java project with Gradle
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
33

4-
name: Java CI with Gradle
4+
name: Build JavaBot
55

6-
on:
7-
push:
8-
branches: [ main ]
9-
pull_request:
10-
branches: [ main ]
6+
on: [push, pull_request]
117

128
jobs:
139
build:
14-
1510
runs-on: ubuntu-latest
16-
1711
steps:
1812
- uses: actions/checkout@v2
1913
- name: Set up JDK 17

.github/workflows/publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Build Docker image
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v2
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
- name: Build with Gradle
23+
run: ./gradlew build
24+
- name: Test with Gradle
25+
run: ./gradlew test
26+
- name: Build JAR
27+
run: ./gradlew shadowJar
28+
- name: Build Docker image
29+
run: docker build -t javabot .
30+
- name: Tag docker image
31+
run: |
32+
docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:${{ github.sha }}
33+
docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:latest
34+
env:
35+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
if: env.dockerhub_username != null
37+
- name: Login to DockerHub
38+
uses: docker/login-action@v2
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
env:
43+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
if: env.dockerhub_username != null
45+
- name: Push to Docker Hub
46+
run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
47+
env:
48+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
49+
if: env.dockerhub_username != null

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build/
66
/config
77
/purgeArchives
88
/logs
9+
/db
910

1011
# Eclipse settings
1112
.classpath
@@ -14,6 +15,6 @@ build/
1415
bin/
1516

1617
# H2 Database
17-
/*.mv.db
18-
/*.trace.db
19-
/*.lock.db
18+
*.mv.db
19+
*.trace.db
20+
*.lock.db

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM eclipse-temurin:21-jre
2+
RUN mkdir /work
3+
COPY build/libs/JavaBot-1.0.0-SNAPSHOT-all.jar /work/bot.jar
4+
WORKDIR /work
5+
RUN chown 1000:1000 /work
6+
VOLUME "/work/config"
7+
VOLUME "/work/logs"
8+
VOLUME "/work/db"
9+
VOLUME "/work/purgeArchives"
10+
USER 1000
11+
ENTRYPOINT [ "java", "-jar", "bot.jar" ]

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ dependencies {
5353
implementation("com.github.DynxstyGIT:discord-webhooks:74301a46a0")
5454

5555
// Lombok Annotations
56-
compileOnly("org.projectlombok:lombok:1.18.24")
57-
annotationProcessor("org.projectlombok:lombok:1.18.24")
58-
testCompileOnly("org.projectlombok:lombok:1.18.24")
59-
testAnnotationProcessor("org.projectlombok:lombok:1.18.24")
56+
compileOnly("org.projectlombok:lombok:1.18.30")
57+
annotationProcessor("org.projectlombok:lombok:1.18.30")
58+
testCompileOnly("org.projectlombok:lombok:1.18.30")
59+
testAnnotationProcessor("org.projectlombok:lombok:1.18.30")
6060

6161
// Sentry
6262
implementation("io.sentry:sentry:6.3.0")

gradle/wrapper/gradle-wrapper.jar

-15.4 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)