Skip to content

Commit

Permalink
Merge pull request #44 from Happy-HOBAK/feat/#30
Browse files Browse the repository at this point in the history
[#30] ELB & Github Action์„ ์ด์šฉํ•œ CI/CD ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์ถ•
  • Loading branch information
yel-m authored May 3, 2024
2 parents 350baeb + bfe621a commit 103781a
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .ebextensions_dev/00-makeFiles.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
files:
"/sbin/appstart":
mode: "000755"
owner: webapp
group: webapp
content: |
#!/usr/bin/env bash
JAR_PATH=/var/app/current/application.jar

# run app
killall java
java -Dfile.encoding=UTF-8 -jar $JAR_PATH
3 changes: 3 additions & 0 deletions .ebextensions_dev/01-set-timezone.config
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
64 changes: 64 additions & 0 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 1. ์›Œํฌ ํ”Œ๋กœ ์ด๋ฆ„ ์ง€์ •
name: HappinesSQL

# 2. ์›Œํฌํ”Œ๋กœ๊ฐ€ ์‹œ์ž‘๋  ์กฐ๊ฑด ์ง€์ •
on:
pull_request:
types: [closed]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest # 3. ์‹คํ–‰ ํ™˜๊ฒฝ ์ง€์ •
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'

# 4. ์‹คํ–‰ ์Šคํ… ์ง€์ •
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17 # ์ž๋ฐ” ์„ค์น˜
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash # ๊ถŒํ•œ ๋ถ€์—ฌ

- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash # build ์‹œ์ž‘

- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00" # build ์‹œ์ ์˜ ์‹œ๊ฐ„ํ™•๋ณด

- name: Show Current Time
run: echo "CurrentTime=$"
shell: bash # ํ™•๋ณดํ•œ ์‹œ๊ฐ„ ๋ณด์—ฌ์ฃผ๊ธฐ

- name: Generate deployment package
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions_dev deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v20
with:
aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}
application_name: happinessql-dev
environment_name: Happinessql-dev-env
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
region: ap-northeast-2
deployment_package: deploy/deploy.zip
wait_for_deployment: false
1 change: 1 addition & 0 deletions .platform/conf.d/client_max_body_size.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_max_body_size 200M;
63 changes: 63 additions & 0 deletions .platform/nginx.conf
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;
}
}
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: appstart
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

jar {
enabled = false
}
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ spring:
# S3
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
max-file-size: 100MB
max-request-size: 100MB


cloud:
Expand All @@ -36,6 +36,6 @@ cloud:
region:
static: ap-northeast-2 # ๋ฒ„ํ‚ท ๋ฆฌ์ „
s3:
bucket: happinessql # ๋ฒ„ํ‚ท ์ด๋ฆ„
bucket: i-want-to-be-happy # ๋ฒ„ํ‚ท ์ด๋ฆ„
stack:
auto: false

0 comments on commit 103781a

Please sign in to comment.