diff --git a/.github/workflows/dev-cd-jobs.yml b/.github/workflows/dev-cd-jobs.yml new file mode 100644 index 0000000..cd6ec37 --- /dev/null +++ b/.github/workflows/dev-cd-jobs.yml @@ -0,0 +1,42 @@ +name: Deploy to Develop Environment + +on: + push: + branches: + - develop + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Java 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + + - name: Update Git submodules + run: git submodule update --remote --recursive + + - name: Build and test with Gradle + run: ./gradlew test + + - name: Build and push Docker image + run: ./gradlew clean bootBuildImage -PDOCKERHUB_ID=${{ secrets.DOCKERHUB_ID }} -PDOCKERHUB_TOKEN=${{ secrets.DOCKERHUB_TOKEN }} + + - name: SSH into EC2 instance + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.DEV_EC2_HOST }} + username: ${{ secrets.DEV_EC2_USERNAME }} + key: ${{ secrets.DEV_EC2_PRIVATE_KEY }} + port: ${{ secrets.DEV_EC2_SSH_PORT }} + script: | + docker pull mungmnb777/tteokguk:latest + docker ps -f name=be-server -q | xargs --no-run-if-empty docker container stop + docker ps -a -f name=be-server -q | xargs --no-run-if-empty docker container rm + docker run -d --name be-server -p 80:8080 mungmnb777/tteokguk:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index 87a9a37..0183454 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ out/ ### VS Code ### .vscode/ + +### local properties ### +/src/main/resources/application.yml \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8fbece5..292e1d7 100644 --- a/build.gradle +++ b/build.gradle @@ -48,21 +48,38 @@ dependencies { annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" + + // Actuator + implementation 'org.springframework.boot:spring-boot-starter-actuator' } tasks.named('test') { + systemProperty "spring.profiles.active", "test" useJUnitPlatform() } -task copyGitSubmodule(type: Copy) { +tasks.register('copyGitSubmodule', Copy) { from './tteokguk-config' include '*.yml' into './src/main/resources' } -test { - systemProperty "spring.profiles.active", "test" - useJUnitPlatform() +tasks.named('bootBuildImage') { + environment["BPE_DELIM_JAVA_TOOL_OPTIONS"] = " " + environment["BPE_APPEND_JAVA_TOOL_OPTIONS"] = "-XX:+ExitOnOutOfMemoryError -XX:MaxDirectMemorySize=10M " + + "-XX:MaxMetaspaceSize=100M -XX:ReservedCodeCacheSize=60M -Xss256K" + + def dockerhubId = project.property("DOCKERHUB_ID") + def dockerhubToken = project.property("DOCKERHUB_TOKEN") + + imageName = dockerhubId + "/${project.name}" + publish = true + docker { + publishRegistry { + username = dockerhubId + password = dockerhubToken + } + } } processResources { diff --git a/src/main/java/com/tteokguk/tteokguk/global/security/SecurityConfig.java b/src/main/java/com/tteokguk/tteokguk/global/security/SecurityConfig.java new file mode 100644 index 0000000..cc466a7 --- /dev/null +++ b/src/main/java/com/tteokguk/tteokguk/global/security/SecurityConfig.java @@ -0,0 +1,21 @@ +package com.tteokguk.tteokguk.global.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +public class SecurityConfig { + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + return http + .csrf(AbstractHttpConfigurer::disable) + .formLogin(AbstractHttpConfigurer::disable) + .build(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index a176bd7..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,10 +0,0 @@ -spring: - profiles: - group: - test: - - test - dev: - - dev - db: - - db - default: db