File tree Expand file tree Collapse file tree
java/com/gsm/_8th/class4/backend/task27/domain
test/java/com/gsm/_8th/class4/backend/task27 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,24 +12,26 @@ jobs:
1212 steps :
1313 - name : 📂 Checkout Repository
1414 uses : actions/checkout@v3
15- - name : 📦 Download Artifact
16- uses : actions/download-artifact@v4
17- with :
18- path : build/libs
1915 - name : 🐋 Docker Build
20- run : docker build -t groom-server :test .
16+ run : docker build -t task27 :test .
2117 - name : ⏬ Install Docker Compose
2218 run : |
2319 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2420 sudo chmod +x /usr/local/bin/docker-compose
2521 docker-compose --version
26- - name : 🐋 Docker Run
22+ - name : 🐋 Docker Run (MySQL & Redis)
2723 run : docker-compose -f compose.yaml up -d
24+ - name : ⌛ Wait for Services
25+ run : sleep 30
26+ - name : 🐋 Run Task.2-7 Server Container
27+ run : docker run --name task27-server --network=compose_default -d -p 8080:8080 task27:test
2828 - name : ⌛ Wait for Application
2929 run : sleep 45
30+ - name : 🧪 Log Trace
31+ run : docker logs task27-server
3032 - name : 🧪 Test Application
3133 run : |
32- RESPONSE=$(curl -s "http://127.0.0.1 :8080/health/check")
34+ RESPONSE=$(curl -s "http://localhost :8080/health/check")
3335 if [ "$RESPONSE" != "OK" ]; then
3436 echo "💣 Health Check Failed"
3537 exit 1
Original file line number Diff line number Diff line change 1- # Dockerfile을 작성하여주세요
1+ FROM openjdk:21-jdk-slim AS base
2+ WORKDIR /app
3+ RUN apt-get update && apt-get install -y curl unzip zip tzdata \
4+ && curl -s https://get.sdkman.io | bash \
5+ && /bin/bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install gradle"
6+ ARG TZ=Asia/Seoul
7+ ENV TZ=${TZ}
8+ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
9+ COPY . /app
10+ RUN chmod +x ./gradlew
11+ RUN ./gradlew clean build --no-daemon
12+ FROM openjdk:21-jdk-slim AS stage-1
13+ RUN groupadd --system appgroup && useradd --system --gid appgroup appuser
14+ WORKDIR /app
15+ COPY --from=base /app/build/libs/task27-0.0.1-SNAPSHOT.jar /app/app.jar
16+ RUN rm -rf /app/.gradle /app/build/tmp /root/.gradle
17+ ENV TZ=${TZ}
18+ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
19+ ENV SPRING_PROFILES_ACTIVE=test
20+ USER appuser
21+ EXPOSE 8080
22+ ENTRYPOINT ["java" , "-jar" , "/app/app.jar" ]
Original file line number Diff line number Diff line change @@ -12,3 +12,6 @@ services:
1212 image : ' redis:latest'
1313 ports :
1414 - ' 6380:6379'
15+ networks :
16+ default :
17+ name : compose_default
Original file line number Diff line number Diff line change 11package com .gsm ._8th .class4 .backend .task27 .domain .healthcheck .controller ;
22
33import org .springframework .http .ResponseEntity ;
4+ import org .springframework .web .bind .annotation .GetMapping ;
45import org .springframework .web .bind .annotation .RequestMapping ;
56import org .springframework .web .bind .annotation .RestController ;
67
78@ RestController
89@ RequestMapping ("/health" )
910public class HealthCheckController {
1011
11- @ RequestMapping ("/check" )
12+ @ GetMapping ("/check" )
1213 public ResponseEntity <String > check () {
1314 return ResponseEntity .ok ("OK" );
1415 }
Original file line number Diff line number Diff line change 77import lombok .RequiredArgsConstructor ;
88import org .springframework .stereotype .Service ;
99
10+ import java .util .Collections ;
1011import java .util .List ;
12+ import java .util .Objects ;
1113import java .util .stream .Collectors ;
1214import java .util .stream .StreamSupport ;
1315
@@ -19,8 +21,11 @@ public class GetAllTokenServiceImpl implements GetAllTokenService {
1921
2022 @ Override
2123 public List <Token > getAllToken () {
22- return StreamSupport .stream (tokenRepository .findAll ().spliterator (), false )
24+ Iterable <TokenEntity > iterable = tokenRepository .findAll ();
25+ return StreamSupport .stream (iterable .spliterator (), false )
26+ .filter (Objects ::nonNull )
2327 .map (TokenEntity ::toDto )
28+ .filter (Objects ::nonNull )
2429 .collect (Collectors .toList ());
2530 }
2631}
Original file line number Diff line number Diff line change 1+ spring :
2+ config :
3+ activate :
4+ on-profile : dev
5+ datasource :
6+ url : jdbc:mysql://localhost:3306/mydatabase
7+ username : myuser
8+ password : secret
9+ driver-class-name : com.mysql.cj.jdbc.Driver
10+ jpa :
11+ hibernate :
12+ ddl-auto : create
13+ show-sql : true
14+ database-platform : org.hibernate.dialect.MySQLDialect
15+ properties :
16+ hibernate :
17+ format_sql : true
18+ data :
19+ redis :
20+ host : localhost
21+ port : 6379
Original file line number Diff line number Diff line change 1+ spring :
2+ config :
3+ activate :
4+ on-profile : test
5+ datasource :
6+ url : jdbc:mysql://mysql:3306/mydatabase
7+ username : myuser
8+ password : secret
9+ driver-class-name : com.mysql.cj.jdbc.Driver
10+ data :
11+ redis :
12+ host : redis
13+ port : 6380
14+ jpa :
15+ hibernate :
16+ ddl-auto : create
17+ show-sql : true
18+ database-platform : org.hibernate.dialect.MySQLDialect
19+ properties :
20+ hibernate :
21+ format_sql : true
Original file line number Diff line number Diff line change 11spring :
22 application :
33 name : task27
4- datasource :
5- url : jdbc:mysql://localhost:3306/mydatabase
6- username : myuser
7- password : secret
8- driver-class-name : com.mysql.cj.jdbc.Driver
9- jpa :
10- hibernate :
11- ddl-auto : create
12- show-sql : true
13- database-platform : org.hibernate.dialect.MySQLDialect
14- properties :
15- hibernate :
16- format_sql : true
17- data :
18- redis :
19- host : localhost
20- port : 6379
4+ profiles :
5+ active : ${SPRING_PROFILES_ACTIVE:dev}
Original file line number Diff line number Diff line change 66@ SpringBootTest
77class Task27ApplicationTests {
88
9- @ Test
10- void contextLoads () {
11- }
12-
13- }
9+ }
You can’t perform that action at this time.
0 commit comments