Skip to content

Commit 237f74e

Browse files
authored
merge: merge test pull request
2 parents b776ec1 + e8d09d6 commit 237f74e

9 files changed

Lines changed: 87 additions & 32 deletions

File tree

.github/workflows/build.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff 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

Dockerfile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
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"]

compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ services:
1212
image: 'redis:latest'
1313
ports:
1414
- '6380:6379'
15+
networks:
16+
default:
17+
name: compose_default

src/main/java/com/gsm/_8th/class4/backend/task27/domain/healthcheck/controller/HealthCheckController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package com.gsm._8th.class4.backend.task27.domain.healthcheck.controller;
22

33
import org.springframework.http.ResponseEntity;
4+
import org.springframework.web.bind.annotation.GetMapping;
45
import org.springframework.web.bind.annotation.RequestMapping;
56
import org.springframework.web.bind.annotation.RestController;
67

78
@RestController
89
@RequestMapping("/health")
910
public class HealthCheckController {
1011

11-
@RequestMapping("/check")
12+
@GetMapping("/check")
1213
public ResponseEntity<String> check() {
1314
return ResponseEntity.ok("OK");
1415
}

src/main/java/com/gsm/_8th/class4/backend/task27/domain/token/service/impl/GetAllTokenServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import lombok.RequiredArgsConstructor;
88
import org.springframework.stereotype.Service;
99

10+
import java.util.Collections;
1011
import java.util.List;
12+
import java.util.Objects;
1113
import java.util.stream.Collectors;
1214
import 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
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

src/main/resources/application.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
spring:
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}

src/test/java/com/gsm/_8th/class4/backend/task27/Task27ApplicationTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@
66
@SpringBootTest
77
class Task27ApplicationTests {
88

9-
@Test
10-
void contextLoads() {
11-
}
12-
13-
}
9+
}

0 commit comments

Comments
 (0)