Skip to content

Commit 1c33781

Browse files
Merge pull request #463 from danthe1st/docker
create docker image via CI
2 parents 2400772 + d3ebadf commit 1c33781

File tree

9 files changed

+264
-152
lines changed

9 files changed

+264
-152
lines changed

.github/workflows/build.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 JavaBot
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v4
15+
with:
16+
java-version: '17'
17+
distribution: 'temurin'
18+
- name: Grant execute permission for gradlew
19+
run: chmod +x gradlew
20+
- name: Build with Gradle
21+
run: ./gradlew build
22+
- name: Test with Gradle
23+
run: ./gradlew test
24+
publish:
25+
runs-on: ubuntu-latest
26+
needs: build
27+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Set up JDK 17
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: '17'
34+
distribution: 'temurin'
35+
- name: Grant execute permission for gradlew
36+
run: chmod +x gradlew
37+
- name: Build JAR
38+
run: ./gradlew shadowJar
39+
- name: Build Docker image
40+
run: docker build -t javabot .
41+
- name: Tag docker image
42+
run: |
43+
docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:${{ github.sha }}
44+
docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:latest
45+
env:
46+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
47+
if: env.dockerhub_username != null
48+
- name: Login to DockerHub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
env:
54+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
if: env.dockerhub_username != null
56+
- name: Push to Docker Hub
57+
run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
58+
env:
59+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
60+
if: env.dockerhub_username != null

.github/workflows/gradle.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.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)