Skip to content

Commit

Permalink
Merge pull request #22 from devAon/feature/21
Browse files Browse the repository at this point in the history
Feature/21
  • Loading branch information
devAon authored Aug 4, 2020
2 parents 3cf4ec9 + 933ba39 commit 40c325a
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 2 deletions.
206 changes: 204 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ AWS์—์„œ ์ œ๊ณตํ•˜๋Š” ์„ฑ๋Šฅ, ์šฉ๋Ÿ‰ ๋“ฑ์„ ์œ ๋™์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ
๊ต‰์žฅํžˆ ๋ฒˆ๊ฑฐ๋กœ์šฐ๋ฏ€๋กœ ์ธ์Šคํ„ด์Šค์˜ IP๊ฐ€ ๋งค๋ฒˆ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๊ณ  ๊ณ ์ • IP๋ฅผ ๊ฐ€์ง€๊ฒŒ ํ•ด์•ผํ•œ๋‹ค.

๊ทธ๋ž˜์„œ ๊ณ ์ •IP๋ฅผ ํ• ๋‹นํ•  ๊ฒƒ์ด๋‹ค.


**๐Ÿ‘ฟ ์ฃผ์˜**
ํƒ„๋ ฅ์  IP๋Š” ์ƒ์„ฑํ•˜๊ณ  EC2 ์„œ๋ฒ„์— ์—ฐ๊ฒฐํ•˜์ง€ ์•Š์œผ๋ฉด ๋น„์šฉ์ด ๋ฐœ์ƒํ•œ๋‹ค.
Expand Down Expand Up @@ -1922,4 +1922,206 @@ Amazon AUrora ๊ต์ฒด ์šฉ์ดํ•˜๋‹ค.
#### โœ RDS ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ

1. MariaDB ๋กœ ์ƒ์„ฑ
2. ํŒŒ๋ผ๋ฏธํ„ฐ ๊ทธ๋ฃน ์ƒ์„ฑ
2. ํŒŒ๋ผ๋ฏธํ„ฐ ๊ทธ๋ฃน ์ƒ์„ฑ











<br><br><br>



## ๐Ÿ“Œ feature-21 : ๋ฐฐํฌ

### ๐Ÿ“ EC2์— ํ”„๋กœ์ ํŠธ clone

sudo yum install git

git --version

mkdir ~/app && mkdir ~/app/step1

cd ~/app/step1

git clone ๊นƒํ—ˆ๋ธŒ http ์ฃผ์†Œ

cd aoneemall

ll

./gradlew test # ์ฝ”๋“œ ์ž˜ ์ˆ˜ํ–‰๋˜๋Š”์ง€ ๊ฒ€์ฆ

git pull #๊ถŒํ•œ์ด ์—†๋‹ค๋ฉด ? chmod +x ./gradlew





<br>



### ๐Ÿ“ ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑ

#### โœ ๋ฐฐํฌ๋ž€ ?

์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ฅผ ์‹ค์ œ ์„œ๋ฒ„์— ๋ฐ˜์˜ํ•˜๋Š” ๊ฒƒ

ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์—์„œ ๋ฐฐํฌ๋Š” ์•„๋ž˜์˜ ๊ณผ์ •์„ ๋ชจ๋‘ ํฌ๊ด„ํ•˜๋Š” ์˜๋ฏธ์ด๋‹ค.

* git clone ํ˜น์€ git pull์„ ํ†ตํ•ด ์ƒˆ ๋ฒ„์ „์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฐ›์Œ
* Gradle ์ด๋‚˜ Maven์„ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ ํ…Œ์ŠคํŠธ์™€ ๋นŒ๋“œ
* EC2 ์„œ๋ฒ„์—์„œ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ ์‹คํ–‰ ๋ฐ ์žฌ์‹คํ–‰



#### โœ ์‰˜ ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑ

deploy.sh ํŒŒ์ผ ์ƒ์„ฑ



```

#! /bin/bash

REPOSITORY=/home/ec2-user/app/step1
PROJECT_NAME=aoneemall

cd $REPOSITORY/$PROJECT_NAME/

echo "> Git Pull"

git pull

echo "> Start Building Project"

./gradlew build

echo "> Change Directory to step1"

cd $REPOSITORY

echo "> Copy Build Files"

cp $REPOSITORY/$PROJECT_NAME/build/libs/*.jar $REPOSITORY/
echo "> Check Current Application Pids"
# pgrep : process id๋งŒ ์ถ”์ถœ
# -f : process ์ด๋ฆ„์œผ๋กœ ๊ฒ€์ƒ‰
CURRENT_PID=$(pgrep -f ${PROJECT_NAME}*.jar)
echo "> Current Application Pids : $CURRENT_PID"
if [ -z "$CURRENT_PID" ] ; then
echo "> ํ˜„์žฌ ๊ตฌ๋™์ค‘์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์—†์œผ๋ฏ€๋กœ ์ข…๋ฃŒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi
echo "> Deploy New Application"
# ์ƒˆ๋กœ ์‹คํ–‰ํ•  jarํŒŒ์ผ ์ฐพ์•„์„œ
# ์—ฌ๋Ÿฌ jarํŒŒ์ผ ์ค‘ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰(์ตœ์‹ ) ํŒŒ์ผ์„ ๋ณ€์ˆ˜์— ์ €์žฅ
JAR_NAME=$(ls -tr $REPOSITORY/ | grep *.jar | tail -n 1)
echo "> JAR NAME : JAR_NAME"
# nohup์œผ๋กœ ํŒŒ์ผ ์‹คํ–‰
# application-oauth.properties ํŒŒ์ผ ์œ„์น˜ ์„ค์ •
nohup java -jar \
-Dspring.config.location=classpath:/application.properties,/home/ec2-user/app/application-oauth.properties \
$REPOSITORY/$JAR_NAME 2>&1 &
```
<br>
**๐Ÿ™‹โ€โ™€๏ธ ์‰˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ์ด์œ ๋Š” ?**
๋ฐฐํฌํ•  ๋•Œ๋งˆ๋‹ค ๊ฐœ๋ฐœ์ž๊ฐ€ ํ•˜๋‚˜ํ•˜๋‚˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์€ ๋งŽ์€ ๋ถˆํŽธํ•จ์ด ๋”ฐ๋ฅธ๋‹ค.
๊ทธ๋ž˜์„œ ์‰˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•ด ์Šคํฌ๋ฆฝํŠธ๋งŒ ์‹คํ–‰ํ•˜๋ฉด ์ฐจ๋ก€๋กœ ์ง„ํ–‰๋˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.
<br>
### ๐Ÿ“ ์™ธ๋ถ€ Securiy ํŒŒ์ผ ๋“ฑ๋ก
์„œ๋ฒ„์— gitignore๋œ application-oauth.properties ์ถ”๊ฐ€
<br>
### ๐Ÿ“ ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ๋กœ RDS ์ ‘๊ทผ
#### โœ ํ…Œ์ด๋ธ” ์ƒ์„ฑ
H2์—์„œ ์ž๋™ ์ƒ์„ฑํ•ด์ฃผ๋˜ ํ…Œ์ด๋ธ”์„ MarialDB์— ์ง์ ‘ ์ฟผ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ์ƒ์„ฑํ•ด์คŒ
<br>
#### โœ ํ”„๋กœ์ ํŠธ ์„ค์ •
์ž๋ฐ” ํ”„๋กœ์ ํŠธ๊ฐ€ MariaDB์— ์ ‘๊ทผํ•˜๋ ค๋ฉด DB Driver๊ฐ€ ํ•„์š”.
build.gradle์— ์˜์กด์„ฑ ์ถ”๊ฐ€
<br>
#### โœ EC2 ์„ค์ •
DB ์ ‘์† ์ •๋ณด๋Š” ์ค‘์š”ํ•˜๊ฒŒ ๋ณดํ˜ธํ•ด์•ผ ํ•  ์ •๋ณด์ด๋‹ค.
๊ณต๊ฐœ๋˜๋ฉด ์™ธ๋ถ€์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ๋‘ ๊ฐ€์ ธ๊ฐˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
ํ”„๋กœ์ ํŠธ ์•ˆ์— ์ ‘์† ์ •๋ณด๋ฅผ ๊ฐ–๊ณ  ์žˆ์œผ๋ฉด ๊นƒํ—ˆ๋ธŒ ๊ฐ™์ด ์˜คํ”ˆ๋œ ๊ณต๊ฐ„์—์„  ๋ˆ„๊ตฌ๋‚˜ ํ•ดํ‚นํ•  ์œ„ํ—˜์ด ์žˆ๋‹ค.
EC2 ์„œ๋ฒ„ ๋‚ด๋ถ€์—์„œ ์ ‘์† ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๋„๋ก ์„ค์ •
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dependencies {
compile('org.springframework.boot:spring-boot-starter-oauth2-client')
compile('org.springframework.session:spring-session-jdbc')

compile('org.mariadb.jdbc:mariadb-java-client')

testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile("org.springframework.security:spring-security-test")
}
3 changes: 3 additions & 0 deletions src/main/resources/application-real.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring.profiles.include=oauth,real-db
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.session.store-type=jdbc

0 comments on commit 40c325a

Please sign in to comment.