-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Team-Shaka/ci/38
๐ท Ci : ci/cd ํ์ดํ๋ผ์ธ ๊ตฌ์ถ
- Loading branch information
Showing
9 changed files
with
315 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
commands: | ||
set_time_zone: | ||
command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: docker ci/cd | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- develop | ||
types: [closed] | ||
workflow_dispatch: # (2).์๋ ์คํ๋ ๊ฐ๋ฅํ๋๋ก | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest # (3).OSํ๊ฒฝ | ||
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) | ||
|
||
|
||
steps: | ||
- name: Checkout current repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 17 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
shell: bash | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: tree-dev | ||
IMAGE_TAG: latest | ||
run: | | ||
# Docker ์ด๋ฏธ์ง ๋น๋ | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
# ๋น๋ํ ์ด๋ฏธ์ง๋ฅผ Amazon ECR๋ก ํธ์ | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
# ๋น๋๋ ์ด๋ฏธ์ง์ ์ ๋ณด ์ถ๋ ฅ | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Get current time | ||
uses: 1466587594/get-current-time@v2 | ||
id: current-time | ||
with: | ||
format: YYYYMMDD_HH-mm-ss | ||
utcOffset: "+09:00" | ||
|
||
- name: Generate deployment package | ||
run: | | ||
mkdir -p deploy | ||
cp -r .ebextensions deploy/.ebextensions | ||
cp Dockerrun.aws.json deploy/Dockerrun.aws.json | ||
cp -r .platform deploy/.platform | ||
cd deploy && zip -r deploy.zip . | ||
- name: Beanstalk Deploy | ||
uses: einaregilsson/beanstalk-deploy@v14 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: tree-dev | ||
environment_name: Tree-dev-env | ||
version_label: github-action-${{ steps.current-time.outputs.formattedTime }} | ||
region: ap-northeast-2 | ||
deployment_package: deploy/deploy.zip | ||
wait_for_deployment: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
user nginx; | ||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
worker_processes auto; | ||
worker_rlimit_nofile 33282; | ||
|
||
events { | ||
use epoll; | ||
worker_connections 1024; | ||
multi_accept on; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
include conf.d/*.conf; | ||
|
||
map $http_upgrade $connection_upgrade { | ||
default "upgrade"; | ||
} | ||
|
||
upstream springboot { | ||
server 127.0.0.1:8080; | ||
keepalive 1024; | ||
} | ||
|
||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
|
||
location / { | ||
proxy_pass http://springboot; | ||
# CORS ๊ด๋ จ ํค๋ ์ถ๊ฐ | ||
add_header 'Access-Control-Allow-Origin' '*'; | ||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; | ||
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type'; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_set_header Upgrade $http_upgrade; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
client_header_timeout 60; | ||
client_body_timeout 60; | ||
keepalive_timeout 60; | ||
gzip off; | ||
gzip_comp_level 4; | ||
|
||
# Include the Elastic Beanstalk generated locations | ||
include conf.d/elasticbeanstalk/healthd.conf; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ๊ธฐ๋ณธ ์ด๋ฏธ์ง ์ค์ | ||
FROM eclipse-temurin:17-jdk | ||
|
||
# ํ์ฌ ๋ฆฌํฌ์งํ ๋ฆฌ, api gateway์ ์ฝ๋๋ฅผ ๋ฐํ์ผ๋ก JAR ์์ฑ | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# ์ต์ข ์ด๋ฏธ์ง ์์ฑ | ||
FROM eclipse-temurin:17-jdk | ||
COPY --from=0 app.jar app.jar | ||
|
||
# ์ ํ๋ฆฌ์ผ์ด์ ์คํ ์คํฌ๋ฆฝํธ ์ถ๊ฐ | ||
COPY dev_start.sh start.sh | ||
RUN chmod +x dev_start.sh | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["./start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"AWSEBDockerrunVersion": "1", | ||
"Image": { | ||
"Name": "851725177732.dkr.ecr.ap-northeast-2.amazonaws.com/tree-dev:latest", | ||
"Update": "true" | ||
}, | ||
"Ports": [ | ||
{ | ||
"ContainerPort": "8080" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์คํ | ||
java -jar -Dspring.profiles.active=common,dev app.jar & | ||
|
||
# ๋ชจ๋ ์์ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ๋๊ธฐ | ||
wait |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/example/tree/domain/root/controller/RootController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.example.tree.domain.root.controller; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class RootController { | ||
|
||
@GetMapping("/health") | ||
public String healthCheck(){ | ||
return "I'm healty!"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# default profile | ||
spring: | ||
application: | ||
name: tree-server | ||
profiles: | ||
group: | ||
dev: common, dev | ||
|
||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "common" | ||
springdoc: | ||
swagger-ui: | ||
tags-sorter: alpha # alpha: ์ํ๋ฒณ ์ ํ๊ทธ ์ ๋ ฌ, method: HTTP Method ์ ์ ๋ ฌ | ||
operations-sorter: alpha # alpha: ์ํ๋ฒณ ์ ํ๊ทธ ์ ๋ ฌ, method: HTTP Method ์ ์ ๋ ฌ | ||
cache: | ||
disabled: true | ||
use-fqn: true | ||
--- | ||
spring: | ||
application: | ||
name: tree-server-dev | ||
config: | ||
activate: | ||
on-profile: "dev" | ||
datasource: | ||
username: ${aws.db.username} | ||
password: ${aws.db.password} | ||
url: jdbc:mysql://${aws.db.url}/${aws.db.name}?autoReconnect=true&setTimezone=Asia/Seoul | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
sql: | ||
init: | ||
mode: never | ||
jpa: | ||
properties: | ||
hibernate: | ||
dialect: org.hibernate.dialect.MySQLDialect | ||
show_sql: true | ||
format_sql: true | ||
use_sql_comments: true | ||
hbm2ddl: | ||
auto: update | ||
default_batch_fetch_size: 1000 | ||
jwt: | ||
header: Authorization | ||
# dev server | ||
secret: | ||
key: ${JWT_SECRET} | ||
# secret : ${JWT_SECRET} | ||
authorities-key: authoritiesKey | ||
access-token-validity-in-seconds: 1210000000 # 30 m | ||
refresh-token-validity-in-seconds: 1210000000 # 14 d | ||
|
||
--- | ||
#spring: | ||
# config: | ||
# activate: | ||
# on-profile: release | ||
# datasource: | ||
# username: ${aws.db.username} | ||
# password: ${aws.db.password} | ||
# url: ${aws.db.url} | ||
# driver-class-name: com.mysql.cj.jdbc.Driver | ||
# sql: | ||
# init: | ||
# mode: never | ||
# jpa: | ||
# properties: | ||
# hibernate: | ||
# dialect: org.hibernate.dialect.MySQLDialect | ||
# # show_sql: true | ||
# # format_sql: true | ||
# use_sql_comments: true | ||
# hbm2ddl: | ||
# auto: update | ||
# default_batch_fetch_size: 1000 | ||
# data: | ||
# redis: | ||
# host: ${release.redis.host} | ||
# port: 6379 | ||
#jwt: | ||
# header: Authorization | ||
# # dev server | ||
# secret: ${JWT_SECRET} | ||
# # secret : ${JWT_SECRET} | ||
# authorities-key: authoritiesKey | ||
# access-token-validity-in-seconds: 1210000000 # 30 m | ||
# refresh-token-validity-in-seconds: 1210000000 # 14 d | ||
# | ||
#openai: | ||
# token: ${OPEN_API_TOKEN} | ||
# url: | ||
# chat: https://api.openai.com/v1/chat/completions |