-
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.
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 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,8 @@ | ||
files: | ||
"/sbin/appstart" : | ||
mode: "000755" | ||
owner: webapp | ||
group: webapp | ||
content: | | ||
kill `ps -ef | grep cmc-dev-api | awk '{print $2}'` | ||
java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-dev-api.jar |
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,26 @@ | ||
files: | ||
"/home/ec2-user/setup_swap.sh": | ||
mode: "000755" | ||
owner: root | ||
group: root | ||
content: | | ||
#!/bin/bash | ||
# based on http://steinn.org/post/elasticbeanstalk-swap/ | ||
|
||
SWAPFILE=/var/swapfile | ||
SWAP_MEGABYTES=2048 | ||
|
||
if [ -f $SWAPFILE ]; then | ||
echo "Swapfile $SWAPFILE found, assuming already setup" | ||
exit; | ||
fi | ||
|
||
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES | ||
/bin/chmod 600 $SWAPFILE | ||
/sbin/mkswap $SWAPFILE | ||
/sbin/swapon $SWAPFILE | ||
|
||
commands: | ||
01setup_swap: | ||
command: "bash setup_swap.sh" | ||
cwd: "/home/ec2-user/" |
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,76 @@ | ||
name: prod CMC API Server BeanStalk CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ prod ] | ||
workflow_dispatch: # 수동 실행 옵션 (생략) | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest # action 스크립트가 작동될 OS | ||
|
||
steps: # 작업 단계 | ||
- name: Checkout source code # 단계별 이름, 구분자로 소스를 가져옴 | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
|
||
- name: Set Environment - Common Yml | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: src/main/resources/application-common.yml | ||
env: | ||
jwt.secret: ${{ secrets.JWT_SECRET_KEY }} | ||
jwt.refresh: ${{ secrets.JWT_REFRESH_KEY }} | ||
spring.mail.password: ${{ secrets.MAIL_PASSWORD}} | ||
|
||
- name: Set Environment Domain - Domain PROD Yml | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: src/main/resources/application-domain-prod.yml | ||
env: | ||
spring.datasource.url: ${{ secrets.PROD_DB_URL_HOST }} | ||
spring.datasource.username: ${{ secrets.AWS_DB_USER_NAME }} | ||
spring.datasource.password: ${{ secrets.AWS_DB_PASSWORD }} | ||
spring.data.redis.host: ${{ secrets.DEV_REDIS_HOST }} | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
shell: bash | ||
|
||
- name: Get current time | ||
uses: 1466587594/get-current-time@v2 | ||
id: current-time | ||
with: | ||
format: YYYYMMDDTHHmm | ||
utcOffset: "+09:00" | ||
|
||
- name: Generate deployment package | ||
run: | | ||
mkdir -p deploy | ||
cp build/libs/*.jar deploy/cmc-dev-api.jar | ||
cp Procfile deploy/Procfile | ||
cp -r .ebextensions-prod deploy/.ebextensions | ||
cp -r .platform deploy/.platform | ||
cd deploy && zip -r cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} . | ||
- name: Deploy Consumer to EB | ||
uses: einaregilsson/beanstalk-deploy@v19 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} | ||
application_name: CmcApiServerDev | ||
environment_name: CmcApiServerDev-env | ||
version_label: cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} | ||
region: ap-northeast-2 | ||
deployment_package: deploy/cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}}.zip | ||
wait_for_deployment: false |