Skip to content

Commit aa4bb2a

Browse files
authored
🚚 Chore : optimize docker / gh-actions (#6)
* 🚚 Chore : docker-compose-v2 compatibility * 🚚 Chore : optimizing GitHub Actions caching strategy --------- Signed-off-by: Hyeon-hak Kim <[email protected]>
1 parent 388d68c commit aa4bb2a

File tree

6 files changed

+55
-39
lines changed

6 files changed

+55
-39
lines changed

β€Ž.dockerignore

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
.gradle
2-
build
1+
.github
32
.idea
4-
*.jar
5-
*.war
3+
.env.example
4+
.env.local
5+
.gitignore
6+
README.md
7+
.gitmessage
8+
LICENSE
9+
SunStyle_edited.xml
10+
codecov.yml
11+
docker-compose.yaml

β€Ž.github/workflows/gradle-test-main.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ on:
77

88
jobs:
99
build_test_and_coverage:
10-
runs-on: ${{ matrix.os }}
11-
strategy:
12-
matrix:
13-
os: [ ubuntu-latest, macos-latest ]
14-
java: [ '21' ]
10+
runs-on: 'ubuntu-latest'
1511
steps:
1612
- uses: actions/checkout@v4
1713

1814
- uses: actions/setup-java@v4
1915
with:
2016
distribution: 'liberica'
21-
java-version: ${{ matrix.java }}
22-
cache: 'gradle'
17+
java-version: '21'
2318

2419
- name: Grant execute permission for gradlew
2520
run: chmod +x gradlew
@@ -28,7 +23,6 @@ jobs:
2823
run: ./gradlew clean test
2924

3025
- name: Upload test coverage to Codecov.io
31-
if: matrix.os == 'ubuntu-latest'
3226
uses: codecov/codecov-action@v4
3327
with:
3428
token: ${{ secrets.CODECOV_TOKEN }}

β€Ž.github/workflows/gradle-test.yml

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run gradlew test
1+
name: Run gradlew test on Ubuntu and MacOS
22

33
on:
44
pull_request:
@@ -7,33 +7,58 @@ on:
77
- feature/**
88

99
jobs:
10-
build_test_and_coverage:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
matrix:
14-
os: [ ubuntu-latest, macos-latest ]
15-
java: [ '21' ]
10+
build_and_test_ubuntu:
11+
runs-on: ubuntu-latest
1612
steps:
1713
- uses: actions/checkout@v4
1814

1915
- uses: actions/setup-java@v4
2016
with:
2117
distribution: 'liberica'
22-
java-version: ${{ matrix.java }}
18+
java-version: '21'
2319
cache: 'gradle'
2420

21+
- uses: actions/cache@v4
22+
with:
23+
path: ~/.gradle/caches
24+
key: gradle-${{ hashFiles('**/*gradle*') }}
25+
restore-keys: gradle-
26+
2527
- name: Grant execute permission for gradlew
2628
run: chmod +x gradlew
2729

2830
- name: Run gradlew test
2931
run: ./gradlew test --warning-mode=all
3032

3133
- name: Upload test coverage to Codecov.io
32-
if: matrix.os == 'ubuntu-latest'
3334
uses: codecov/codecov-action@v4
3435
with:
3536
token: ${{ secrets.CODECOV_TOKEN }}
3637
slug: ${{ github.repository }}
3738
fail_ci_if_error: true
3839
verbose: true
3940
flags: ${{ github.ref == 'refs/pull/develop' && 'integration' || 'unittests' }}
41+
42+
build_and_test_macos:
43+
runs-on: macos-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- uses: actions/setup-java@v4
48+
with:
49+
distribution: 'liberica'
50+
java-version: '21'
51+
cache: 'gradle'
52+
53+
- uses: actions/cache@v4
54+
with:
55+
path: ~/.gradle/caches
56+
key: gradle-${{ hashFiles('**/*gradle*') }}
57+
restore-keys: gradle-
58+
59+
60+
- name: Grant execute permission for gradlew
61+
run: chmod +x gradlew
62+
63+
- name: Run gradlew test
64+
run: ./gradlew test --warning-mode=all

β€Ž.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ build
55
!**/src/main/**/build/
66
!**/src/test/**/build/
77

8-
### IntelliJ IDEA ###
8+
### IDE ###
99
.idea
1010
.vscode
11+
.jpb
1112

1213
# virtual machine crash logs
1314
# see http://www.java.com/en/download/help/error_hotspot.xml

β€ŽDockerfile

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Stage 1: Build the application
2-
FROM bellsoft/liberica-openjdk-alpine:21 as build
3-
WORKDIR /app
4-
COPY src ./src
5-
COPY build.gradle.kts .
6-
COPY dumpJsa.gradle.kts .
7-
COPY gradlew .
8-
COPY gradle ./gradle
9-
RUN chmod +x ./gradlew
10-
RUN --mount=type=cache,target=/root/.gradle ./gradlew build
2+
FROM bellsoft/liberica-openjdk-alpine:21 as builder
3+
LABEL maintainer="ooMia"
4+
COPY . .
5+
CMD ["./gradlew", "build", "--no-daemon"]
116

127
# Stage 2: Run the application
13-
FROM bellsoft/liberica-openjre-alpine:21 as run
14-
WORKDIR /app
15-
COPY --from=build /app/build/libs/*.jar app.jar
16-
EXPOSE 8080
17-
ENTRYPOINT ["java","-jar","app.jar"]
8+
FROM bellsoft/liberica-openjre-alpine:21 AS runner
9+
COPY --from=builder /build/libs/*.jar app.jar
10+
ENTRYPOINT ["java", "-jar", "app.jar"]

β€Ždocker-compose.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#file: noinspection SpellCheckingInspection
2-
version: "3.8"
3-
41
x-mysql-template: &mysql-template
52
image: mysql:latest
63
env_file:

0 commit comments

Comments
Β (0)