Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: ECR에 image push하는 스크립트 추가 및 서버 에러 수정 #15

Merged
merged 10 commits into from
Jan 12, 2024
41 changes: 41 additions & 0 deletions .github/workflows/packy-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: packy API Server - CD

on:
push:
branches:
- develop

permissions:
contents: read

jobs:
CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTION_TOKEN }}
submodules: true

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GitHubActions
role-to-assume: ${{ secrets.ROLE_ARN }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build with Gradle
run: ./gradlew -Pdev clean jib -x test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ out/

### application.yml ###
/packy-api/src/main/resources/
/packy-domain/src/main/resources/
9 changes: 8 additions & 1 deletion packy-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id 'com.google.cloud.tools.jib' version '3.4.0'
}

group = 'com.dilly'
Expand Down Expand Up @@ -34,7 +35,7 @@ dependencies {
// webflux (for WebClient)
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// TODO: Remove this dependency
// json parser
implementation 'com.google.code.gson:gson:2.8.7'
}

Expand All @@ -49,5 +50,11 @@ tasks.register('copySecret', Copy) {
into './src/main/resources'
}

if (project.hasProperty('dev')) {
apply from: project.file('profile-dev.gradle');
} else if (project.hasProperty('prod')) {
apply from: project.file('profile-prod.gradle');
}

bootJar.enabled = true
jar.enabled = false
20 changes: 20 additions & 0 deletions packy-api/profile-dev.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
jib {
from {
image = "amazoncorretto:17.0.4-al2"
platforms {
platform {
architecture = "arm64"
os = "linux"
}
}
}
to {
image = "714646531644.dkr.ecr.ap-northeast-2.amazonaws.com/packy-dev"
tags = ["latest", "${project.name}-" + System.currentTimeMillis()]
}
container {
creationTime = "USE_CURRENT_TIMESTAMP"
jvmFlags = ['-Dspring.profiles.active=dev', '-XX:+UseContainerSupport']
ports = ['8082']
}
}
20 changes: 20 additions & 0 deletions packy-api/profile-prod.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
jib {
from {
image = "amazoncorretto:17.0.4-al2"
platforms {
platform {
architecture = "arm64"
os = "linux"
}
}
}
to {
image = "714646531644.dkr.ecr.ap-northeast-2.amazonaws.com/packy-prod"
tags = ["latest", "${project.name}-" + System.currentTimeMillis()]
}
container {
creationTime = "USE_CURRENT_TIMESTAMP"
jvmFlags = ['-Dspring.profiles.active=prod', '-XX:+UseContainerSupport']
ports = ['8083']
}
}
19 changes: 19 additions & 0 deletions packy-api/src/main/java/com/dilly/admin/api/AdminController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.dilly.admin.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dilly.global.response.DataResponseDto;

@RestController
@RequestMapping("/api/v1/admin")
public class AdminController {

@GetMapping("/health")
public DataResponseDto<String> healthCheck() {
String activeProfile = System.getProperty("spring.profiles.active");

return DataResponseDto.from("This is " + activeProfile + " server!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DataResponseDto<JwtResponse> signUp(
}

@GetMapping("/token/kakao/{code}")
public DataResponseDto<String> getKakaoAccessToken(@PathVariable String code) {
public DataResponseDto<String> getKakaoAccessToken(@PathVariable(name = "code") String code) {
return DataResponseDto.from(kakaoService.getKakaoAccessToken(code));
}
}
7 changes: 7 additions & 0 deletions packy-domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,12 @@ test {
useJUnitPlatform()
}

processResources.dependsOn('copySecret')
tasks.register('copySecret', Copy) {
from '../packy-submodule/domain'
include '*'
into './src/main/resources'
}

bootJar.enabled = false
jar.enabled = true
15 changes: 15 additions & 0 deletions packy-domain/src/main/java/com/dilly/global/config/JpaConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dilly.global.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@Configuration
@EnableJpaRepositories(basePackages = "com.dilly",
excludeFilters = @ComponentScan.Filter(
type = FilterType.ASPECTJ, pattern = "com.dilly.jwt.*"
)
)
public class JpaConfig {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dilly.global.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;

@Configuration
@EnableRedisRepositories(basePackages = "com.dilly.jwt")
public class RedisConfig {
}
21 changes: 0 additions & 21 deletions packy-domain/src/main/resources/application-domain.yml

This file was deleted.

2 changes: 1 addition & 1 deletion packy-submodule