Skip to content

Commit 1ef2977

Browse files
authored
Merge branch 'develop' into feature/#297
2 parents 33c1093 + ef1e011 commit 1ef2977

File tree

38 files changed

+573
-115
lines changed

38 files changed

+573
-115
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
commands:
2+
set_time_zone:
3+
command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime

.github/ISSUE_TEMPLATE/ci.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: "CI"
2+
name: "CI/CD"
33
about: 배포 작업 템플릿입니다.
4-
title: "ci: "
4+
title: "ci/cd: "
55
labels: ci
66
assignees: ''
77

.github/ISSUE_TEMPLATE/test.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: "TEST"
3+
about: 테스트 작업 템플릿입니다.
4+
title: "test: "
5+
labels: test
6+
assignees: ''
7+
8+
---
9+
10+
# Title
11+
12+
- title
13+
14+
# TODO
15+
16+
- [ ] write what to do
17+
18+
# etc
19+
20+
- nothing

.github/workflows/cd_gradle.yml

+50-42
Original file line numberDiff line numberDiff line change
@@ -50,54 +50,62 @@ jobs:
5050
5151
# 빌드 및 테스트 단계.
5252
- name: Grant execute permission for gradlew
53-
run: chmod +x gradlew
53+
run: chmod +x ./gradlew
5454

5555
# gradle build
5656
- name: Build with Gradle
57-
run: ./gradlew build -x test
57+
run: ./gradlew clean build -x test
5858

59-
# push 하기 위해 로그인
60-
- name: Docker Hub 로그인
61-
uses: docker/login-action@v3
59+
- name: Configure AWS credentials
60+
uses: aws-actions/configure-aws-credentials@v1
6261
with:
63-
username: ${{ secrets.DOCKER_USERNAME }}
64-
password: ${{ secrets.DOCKER_PASSWORD }}
62+
aws-access-key-id: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}
63+
aws-secret-access-key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}
64+
aws-region: ap-northeast-2
6565

66-
#도커 빌드 & 이미지 push
67-
- name: Docker build & Push
66+
- name: Login to Amazon ECR
67+
id: login-ecr
68+
uses: aws-actions/amazon-ecr-login@v1
69+
70+
- name: Build, tag, and push image to Amazon ECR
71+
id: build-image
72+
env:
73+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
74+
ECR_REPOSITORY: beanstalk
75+
IMAGE_TAG: latest
76+
run: |
77+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
78+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
79+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
80+
81+
82+
- name: Get current time
83+
uses: 1466587594/get-current-time@v2
84+
id: current-time
85+
with:
86+
format: YYYY-MM-DDTHH-mm-ss
87+
utcOffset: "+09:00"
88+
89+
- name: Show Current Time
90+
run: echo "CurrentTime=${{ steps.current-time.outputs.formattedTime }}"
91+
shell: bash
92+
93+
- name: Generate deployment package
6894
run: |
69-
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/sponus-docker .
70-
docker push ${{ secrets.DOCKER_USERNAME }}/sponus-docker
95+
mkdir -p deploy
96+
cp -r .ebextensions-dev deploy/.ebextensions
97+
cp -r .platform deploy/.platform
98+
cp Dockerrun.aws.json deploy/Dockerrun.aws.json
99+
cd deploy && zip -r deploy.zip .
71100
72-
# Docker 파일을 EC2 서버에 배포
73-
- name: Deploy to Prod
74-
uses: appleboy/ssh-action@master
75-
id: deploy-prod
101+
- name: Beanstalk Deploy
102+
uses: einaregilsson/beanstalk-deploy@v20
76103
with:
77-
host: ${{ secrets.HOST }}
78-
username: ec2-user
79-
key: ${{ secrets.PRIVATE_KEY }}
80-
port: 22
81-
script: |
82-
if [ ! -z "$(docker ps -q)" ]; then
83-
docker stop $(docker ps -q)
84-
fi
85-
86-
if [ ! -z "$(docker ps -aq)" ]; then
87-
docker rm $(docker ps -aq)
88-
fi
89-
90-
if [ ! -z "$(docker network ls -qf name=my-network)" ]; then
91-
docker network rm my-network
92-
fi
93-
94-
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
95-
96-
docker pull ${{ secrets.DOCKER_USERNAME }}/sponus-docker
97-
docker pull redis
98-
docker network create my-network
99-
100-
docker run --name my-redis --network my-network -d redis
101-
docker run -e SPRING_PROFILES_ACTIVE=prod -it -d -p 8080:8080 --name sponus-docker -e TZ=Asia/Seoul --network my-network ${{ secrets.DOCKER_USERNAME }}/sponus-docker
102-
103-
docker system prune -f
104+
aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}
105+
aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}
106+
application_name: project-prod-study
107+
environment_name: Project-prod-study-env
108+
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
109+
region: ap-northeast-2
110+
deployment_package: deploy/deploy.zip
111+
wait_for_deployment: false

.github/workflows/ci_gradle.yml

+17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,24 @@ jobs:
1717
with:
1818
java-version: '17'
1919
distribution: 'temurin'
20+
21+
## create application.yml
22+
- name: make application-secret.yml
23+
run: |
24+
mkdir -p ./api/src/main/resources
25+
touch ./api/src/main/resources/application-secret.yml
26+
shell: bash
27+
- name: deliver application-secret.yml
28+
run: echo "${{ secrets.APPLICATION_SECRET }}" > ./api/src/main/resources/application-secret.yml
29+
shell: bash
30+
31+
- name: Start Docker Compose
32+
run: docker-compose -f docker-compose-test.yml up -d
33+
2034
- name: Grant execute permission for gradlew
2135
run: chmod +x gradlew
2236
- name: Test with Gradle
2337
run: ./gradlew test
38+
39+
- name: Stop Docker Compose
40+
run: docker-compose -f docker-compose-test.yml down

.platform/nginx.conf

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
user nginx;
2+
error_log /var/log/nginx/error.log warn;
3+
pid /var/run/nginx.pid;
4+
worker_processes auto;
5+
worker_rlimit_nofile 33282;
6+
7+
events {
8+
use epoll;
9+
worker_connections 1024;
10+
multi_accept on;
11+
}
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
18+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
19+
'$status $body_bytes_sent "$http_referer" '
20+
'"$http_user_agent" "$http_x_forwarded_for"';
21+
22+
include conf.d/*.conf;
23+
24+
map $http_upgrade $connection_upgrade {
25+
default "upgrade";
26+
}
27+
28+
upstream springboot {
29+
server 127.0.0.1:8080;
30+
keepalive 1024;
31+
}
32+
33+
server {
34+
listen 80 default_server;
35+
listen [::]:80 default_server;
36+
37+
location / {
38+
proxy_pass http://springboot;
39+
# CORS 관련 헤더 추가
40+
add_header 'Access-Control-Allow-Origin' '*';
41+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
42+
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
43+
proxy_http_version 1.1;
44+
proxy_set_header Connection $connection_upgrade;
45+
proxy_set_header Upgrade $http_upgrade;
46+
47+
proxy_set_header Host $host;
48+
proxy_set_header X-Real-IP $remote_addr;
49+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50+
}
51+
52+
access_log /var/log/nginx/access.log main;
53+
54+
client_header_timeout 60;
55+
client_body_timeout 60;
56+
keepalive_timeout 60;
57+
gzip off;
58+
gzip_comp_level 4;
59+
60+
# Include the Elastic Beanstalk generated locations
61+
include conf.d/elasticbeanstalk/healthd.conf;
62+
}
63+
}

Dockerfile

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
FROM openjdk:17-jdk
2-
ARG JAR_FILE=./api/build/libs/*.jar
1+
# Eclipse Temurin OpenJDK 17 이미지를 사용
2+
FROM eclipse-temurin:17-jdk
3+
ARG JAR_FILE=api/build/libs/*.jar
4+
35
COPY ${JAR_FILE} app.jar
4-
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "/app.jar"]
6+
7+
# Redis 및 supervisord 설치
8+
RUN apt-get update && \
9+
apt-get install -y redis-server supervisor && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
# supervisord 설정 파일 복사
13+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
14+
15+
# 포트 노출
16+
EXPOSE 8080 6379
17+
18+
# supervisord를 사용하여 애플리케이션과 Redis 실행
19+
CMD ["/usr/bin/supervisord"]

Dockerrun.aws.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"AWSEBDockerrunVersion": "1",
3+
"Image": {
4+
"Name": "891377099059.dkr.ecr.ap-northeast-2.amazonaws.com/beanstalk",
5+
"Update": "true"
6+
},
7+
"Ports": [
8+
{
9+
"ContainerPort": "8080",
10+
"HostPort": "8080"
11+
},
12+
{
13+
"ContainerPort": "6379",
14+
"HostPort": "6379"
15+
}
16+
]
17+
}

api/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414

1515
// Validation
1616
implementation 'org.springframework.boot:spring-boot-starter-validation'
17+
testImplementation 'org.projectlombok:lombok:1.18.22'
1718
}
1819
bootJar { enabled = true }
1920
jar { enabled = false }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.sponus.sponusbe.auth.controller;
2+
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class HealthCheck {
8+
9+
@GetMapping("/health")
10+
public String healthCheck() {
11+
return "I'm healthy!";
12+
}
13+
}

api/src/main/java/com/sponus/sponusbe/domain/bookmark/service/BookmarkService.java

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.sponus.coredomain.domain.bookmark.Bookmark;
77
import com.sponus.coredomain.domain.bookmark.repository.BookmarkRepository;
88
import com.sponus.coredomain.domain.organization.Organization;
9-
import com.sponus.coredomain.domain.organization.repository.OrganizationLinkRepository;
109
import com.sponus.coredomain.domain.organization.repository.OrganizationRepository;
1110
import com.sponus.sponusbe.domain.bookmark.dto.request.BookmarkToggleRequest;
1211
import com.sponus.sponusbe.domain.bookmark.dto.response.BookmarkToggleResponse;

api/src/main/java/com/sponus/sponusbe/domain/organization/club/dto/ClubUpdateRequest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
import jakarta.validation.constraints.Size;
1010

1111
public record ClubUpdateRequest(
12-
@NotBlank(message = "동아리 이름은 필수 입력 값입니다.")
13-
@Size(min = 1, max = 13, message = "동아리 이름은 1자 이상 13자 이하로 입력해주세요.")
12+
@NotBlank(message = "[ERROR] 동아리 이름은 필수 입력 값입니다.")
13+
@Size(min = 1, max = 13, message = "[ERROR] 동아리 이름은 1자 이상 13자 이하로 입력해주세요.")
1414
String name,
1515

16-
@Size(max = 300, message = "동아리 설명은 300자 이하로 입력해주세요.")
16+
@Size(max = 300, message = "[ERROR] 동아리 설명은 300자 이하로 입력해주세요.")
1717
String description,
1818

19-
@NotBlank(message = "동아리 이미지 URL은 필수 입력 값입니다.")
19+
@NotBlank(message = "[ERROR] 동아리 이미지 URL은 필수 입력 값입니다.")
2020
String imageUrl,
2121

22-
@Min(value = 0, message = "동아리원 수는 0 이상의 값이어야 합니다.")
22+
@Min(value = 0, message = "[ERROR] 동아리원 수는 0 이상의 값이어야 합니다.")
2323
int memberCount,
2424

25-
@NotNull(message = "동아리 타입은 필수 입력 값입니다.")
25+
@NotNull(message = "[ERROR] 동아리 타입은 필수 입력 값입니다.")
2626
ClubType clubType,
2727

28-
@NotNull(message = "프로필 공개 여부는 필수 입력 값입니다.")
28+
@NotNull(message = "[ERROR] 프로필 공개 여부는 필수 입력 값입니다.")
2929
ProfileStatus profileStatus
3030
) {
3131
}

api/src/main/java/com/sponus/sponusbe/domain/organization/company/dto/CompanyUpdateRequest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
import jakarta.validation.constraints.Size;
1010

1111
public record CompanyUpdateRequest(
12-
@NotBlank(message = "회사 이름은 필수 입력 값입니다.")
13-
@Size(min = 1, max = 13, message = "회사 이름은 1자 이상 13자 이하로 입력해주세요.")
12+
@NotBlank(message = "[ERROR] 회사 이름은 필수 입력 값입니다.")
13+
@Size(min = 1, max = 13, message = "[ERROR] 회사 이름은 1자 이상 13자 이하로 입력해주세요.")
1414
String name,
1515

16-
@Size(max = 300, message = "회사 설명은 300자 이하로 입력해주세요.")
16+
@Size(max = 300, message = "[ERROR] 회사 설명은 300자 이하로 입력해주세요.")
1717
String description,
1818

19-
@NotBlank(message = "회사 이미지 URL은 필수 입력 값입니다.")
19+
@NotBlank(message = "[ERROR] 회사 이미지 URL은 필수 입력 값입니다.")
2020
String imageUrl,
2121

22-
@NotNull(message = "회사 타입은 필수 입력 값입니다.")
22+
@NotNull(message = "[ERROR] 회사 타입은 필수 입력 값입니다.")
2323
CompanyType companyType,
2424

25-
@NotNull(message = "협업 타입은 필수 입력 값입니다.")
25+
@NotNull(message = "[ERROR] 협업 타입은 필수 입력 값입니다.")
2626
CollaborationType collaborationType,
2727

2828
String sponsorshipContent, // 협찬 물품
2929

30-
@NotNull(message = "프로필 공개 여부는 필수 입력 값입니다.")
30+
@NotNull(message = "[ERROR] 프로필 공개 여부는 필수 입력 값입니다.")
3131
ProfileStatus profileStatus
3232
) {
3333
}

api/src/main/java/com/sponus/sponusbe/domain/organization/company/dto/OrganizationGetResponse.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ public record OrganizationGetResponse(
1414
String imageUrl,
1515
int bookmarkCount,
1616
int viewCount,
17-
OrganizationType organizationType
17+
OrganizationType organizationType,
18+
String subType,
19+
boolean isBookmarked
1820
) {
19-
public static OrganizationGetResponse of(Organization organization) {
21+
22+
public static OrganizationGetResponse of(Organization organization, boolean isBookmarked) {
2023
return OrganizationGetResponse.builder()
2124
.id(organization.getId())
2225
.name(organization.getName())
@@ -26,6 +29,8 @@ public static OrganizationGetResponse of(Organization organization) {
2629
.bookmarkCount(organization.getBookmarkCount())
2730
.viewCount(organization.getViewCount())
2831
.organizationType(organization.getOrganizationType())
32+
.subType(organization.getSubType())
33+
.isBookmarked(isBookmarked)
2934
.build();
3035
}
3136
}

0 commit comments

Comments
 (0)