File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .git
2+ .github
3+ .gradle
4+ build
5+ out
6+ .idea
7+ .vscode
8+ * .iml
Original file line number Diff line number Diff line change 1+ FROM eclipse-temurin:17-jdk-jammy AS builder
2+
3+ WORKDIR /workspace
4+
5+ COPY gradlew gradlew
6+ COPY gradlew.bat gradlew.bat
7+ COPY gradle gradle
8+ COPY build.gradle settings.gradle ./
9+ COPY src src
10+
11+ RUN chmod +x gradlew && ./gradlew --no-daemon bootJar
12+
13+ FROM eclipse-temurin:17-jre-jammy AS runtime
14+
15+ WORKDIR /app
16+
17+ COPY --from=builder /workspace/build/libs/*.jar app.jar
18+
19+ EXPOSE 8080
20+
21+ ENTRYPOINT ["java" , "-jar" , "/app/app.jar" ]
Original file line number Diff line number Diff line change @@ -60,6 +60,25 @@ Read these files in order:
6060
6161The app starts on ` http://localhost:8080 ` .
6262
63+ ## Run with Docker
64+
65+ Build and start the app container:
66+
67+ ``` bash
68+ docker compose up --build app
69+ ```
70+
71+ Then open:
72+
73+ - ` http://localhost:8080/api/students `
74+ - ` http://localhost:8080/swagger-ui.html `
75+
76+ To stop it:
77+
78+ ``` bash
79+ docker compose down
80+ ```
81+
6382## Try the API
6483
6584Get the seeded students:
@@ -119,6 +138,12 @@ openapi.yaml
119138./gradlew test
120139```
121140
141+ Run the tests inside a container:
142+
143+ ``` bash
144+ docker compose run --rm test
145+ ```
146+
122147## GitHub CI
123148
124149This repo includes a GitHub Actions workflow at ` .github/workflows/ci.yml ` .
Original file line number Diff line number Diff line change 1+ services :
2+ app :
3+ build :
4+ context : .
5+ dockerfile : Dockerfile
6+ image : java-spring-learning:local
7+ ports :
8+ - " 8080:8080"
9+
10+ test :
11+ image : eclipse-temurin:17-jdk-jammy
12+ working_dir : /workspace
13+ command : ["./gradlew", "--no-daemon", "test"]
14+ volumes :
15+ - .:/workspace
16+ - gradle-cache:/root/.gradle
17+
18+ volumes :
19+ gradle-cache :
You can’t perform that action at this time.
0 commit comments