Skip to content

Commit 997b7c9

Browse files
authored
Merge pull request #27 from woorifisa-projects-3rd/ci/#26-cicd
[CI] ๋ฐฐํฌ ํ…Œ์ŠคํŠธ ๐Ÿ‘ท
2 parents 5854208 + d6962c4 commit 997b7c9

File tree

8 files changed

+186
-0
lines changed

8 files changed

+186
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
files:
2+
"/sbin/appstart":
3+
mode: "000755"
4+
owner: webapp
5+
group: webapp
6+
content: |
7+
#!/usr/bin/env bash
8+
JAR_PATH=/var/app/current/application.jar
9+
10+
# run app
11+
killalljava
12+
java -Dfile.encoding=UTF-8 -Dspring.profiles.active=dev -jar $JAR_PATH
Lines changed: 3 additions & 0 deletions
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
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Resources:
2+
AWSEBV2LoadBalancerListener:
3+
Type: 'AWS::ElasticLoadBalancingV2::Listener'
4+
Properties:
5+
DefaultActions:
6+
- Type: redirect
7+
RedirectConfig:
8+
Protocol: HTTPS
9+
Port: '443'
10+
Host: '#{host}'
11+
Path: '/#{path}'
12+
Query: '#{query}'
13+
StatusCode: HTTP_301
14+
LoadBalancerArn:
15+
Ref: AWSEBV2LoadBalancer
16+
Port: 80
17+
Protocol: HTTP
18+
AWSEBV2LoadBalancerListener443:
19+
Type: 'AWS::ElasticLoadBalancingV2::Listener'
20+
Properties:
21+
Certificates:
22+
- CertificateArn: Replace with Certificate ARN
23+
DefaultActions:
24+
- Type: forward
25+
TargetGroupArn:
26+
Ref: AWSEBV2LoadBalancerTargetGroup
27+
LoadBalancerArn:
28+
Ref: AWSEBV2LoadBalancer
29+
Port: 443
30+
Protocol: HTTPS
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: wekids-baas Dev CI/CD
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
workflow_dispatch: # (2).์ˆ˜๋™ ์‹คํ–‰๋„ ๊ฐ€๋Šฅํ•˜๋„๋ก
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest # (3).OSํ™˜๊ฒฝ
11+
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'test'
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3 # (4).์ฝ”๋“œ check out
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: 17 # (5).์ž๋ฐ” ์„ค์น˜
21+
distribution: 'adopt'
22+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x ./gradlew
25+
shell: bash # (6).๊ถŒํ•œ ๋ถ€์—ฌ
26+
27+
- name: Build with Gradle
28+
run: ./gradlew clean build -x test
29+
shell: bash # (7).build์‹œ์ž‘
30+
31+
- name: Get current time
32+
uses: 1466587594/get-current-time@v2
33+
id: current-time
34+
with:
35+
format: YYYY-MM-DDTHH-mm-ss
36+
utcOffset: "+09:00"# (8).build์‹œ์ ์˜ ์‹œ๊ฐ„ํ™•๋ณด
37+
38+
- name: Show Current Time
39+
run: echo "CurrentTime=$"
40+
shell: bash # (9).ํ™•๋ณดํ•œ ์‹œ๊ฐ„ ๋ณด์—ฌ์ฃผ๊ธฐ
41+
42+
- name: Generate deployment package
43+
run: |
44+
mkdir -p deploy
45+
cp build/libs/*.jar deploy/application.jar
46+
cp Procfile deploy/Procfile
47+
cp -r .ebextensions-dev deploy/.ebextensions
48+
cp -r .platform deploy/.platform
49+
cd deploy && zip -r deploy.zip .
50+
51+
- name: Beanstalk Deploy
52+
uses: einaregilsson/beanstalk-deploy@v20
53+
with:
54+
aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}
55+
aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}
56+
application_name: wekdis-baas-dev
57+
environment_name: Wekdis-baas-dev-env
58+
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
59+
region: ap-northeast-1
60+
deployment_package: deploy/deploy.zip
61+
wait_for_deployment: false

โ€Ž.platform/nginx.confโ€Ž

Lines changed: 63 additions & 0 deletions
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+
}

โ€ŽProcfileโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: appstart

โ€Žbuild.gradleโ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ dependencies {
4141
tasks.named('test') {
4242
useJUnitPlatform()
4343
}
44+
45+
jar {
46+
enabled=false
47+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.wekids.baas.aws;
2+
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class HealthController {
8+
@GetMapping("/health")
9+
public String healthCheck() {
10+
return "I'm healthy";
11+
}
12+
}

0 commit comments

Comments
ย (0)