반응형

1. 시험환경

    ˙ AWS

 

2. 목적

    ˙ AWS Lambda 서비스(함수)를 생성한다.

    ˙ AWS Lambda 함수를 트리거 하기위해 API Gateway를 생성한다.

    ˙ API Gateway에 등록한 URL에 의하여 AWS Lambda 서비스(함수)가 실행되는지 확인한다.

 

3. 적용

    ① AWS Lambda 함수를 생성한다.

 

    ② 람다함수의 코드를 생성하고 "Deploy" 버튼을 클릭한다.

        - Deploy 마다 Log Stream이 1개씩 생성되어 로그가 남겨진다.

 

    ③ AWS Lambda를 실행하기 위한 "트리거 추가" 버튼을 클릭한다.


    ④ 설정정보를 입력하고 "API 게이트웨이"를 생성한다.

 

    ⑤ AWS Lambda 함수에 API Gateway가 연동된 것을 확인한다.

 

    ⑥ API Gateway 기본 경로에 추가 경로 및 방식(ANY, GET, POST 등)을 구성할 수 있다.

 

    ⑦ API Gateway 기본경로에 AWS Lambda 서비스 연결을 설정한다.

 

    ⑧ API Gateway 세부정보에서 URL을 확인한다.

 

4. 결과

    ˙ 트리거 입력에 의하여 AWS Lambda 서비스가 호출되는지 확인한다.

        - URL : http://[API-Gateway-URL]/[기본경로]

 

반응형
반응형

1. 시험환경

    ˙ Springboot

    ˙ React.js

    ˙ build.gradle

 

2. 목적

    ˙ Springboot 프로젝트에서 React.js 프로젝트를 함께 배포한다.

 

3. 적용

    ① Springboot 프로젝트 안에서 React.js 프로젝트를 생성 및 연동하는 방법은 아래 내용을 참고한다.

        - 참고 : https://languagestory.tistory.com/234

 

Springboot 프로젝트에서 React.js 연동 설정

1. 시험환경 ˙ Springboot ˙ Gradle ˙ React.js ˙ axios 2. 목적 ˙ Spring Initializr를 이용하여 Springboot 프로젝트를 생성한다. ˙ React.js 프로젝트를 생성한다. ˙ Springboot와 React.js 연동을 위한 설정한다. ˙ Sprin

languagestory.tistory.com

 

    ② build.gradle에서 React.js 배포를 위한 설정 부분을 추가한다.

        - webDir 변수 : react.js 프로젝트를 생성한 경로

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def webDir = "$projectDir/src/main/web"
 
sourceSets {
    main {
        resources {
            srcDirs = ["$projectDir/src/main/resources"]
        }
    }
}
 
processResources { dependsOn "copyReactBuildFiles" }
 
task installReact(type: Exec) {
    workingDir "$webDir"
    inputs.dir "$webDir"
    group = BasePlugin.BUILD_GROUP
    if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
        commandLine "npm.cmd""audit""fix"
        commandLine 'npm.cmd''install' }
    else {
        commandLine "npm""audit""fix" commandLine 'npm''install'
    }
}
 
task buildReact(type: Exec) {
    dependsOn "installReact"
    workingDir "$webDir"
    inputs.dir "$webDir"
    group = BasePlugin.BUILD_GROUP
    if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
        commandLine "npm.cmd""run-script""build"
    } else {
        commandLine "npm""run-script""build"
    }
}
 
task copyReactBuildFiles(type: Copy) {
    dependsOn "buildReact"
    from "$webDir/build"
    into "$projectDir/src/main/resources/static"
}
 
cs

 

    ③ 프로젝트 경로에서 빌드(build) 한다.

        - 빌드 명령어 : gradlew build

        - 빌드 결과 : [프로젝트홈]/build/libs

 

    ④ 빌드 파일(.jar)를 실행한다.

        - JAR 실행 명령어 : java -jar [빌드파일]

 

4. 결과

    ˙ Web에 접속하여 실행여부를 확인한다. (frontend 확인)

 

    ˙ 빌드파일을 실행한 콘솔로그를 확인한다. (backend 확인)

반응형
반응형

1. 시험환경

    ˙ Springboot

    ˙ Gradle

    ˙ React.js

    ˙ axios

 

2. 목적

    ˙ Spring Initializr를 이용하여 Springboot 프로젝트를 생성한다.

    ˙ React.js 프로젝트를 생성한다.

    ˙ Springboot와 React.js 연동을 위한 설정한다.

    ˙ Springboot와 React.js 배포를 위한 설정한다.

 

3. 적용

    ① 아래 포스팅을 참고하여 Springboot 프로젝트를 생성한다.

        - 참고 : https://languagestory.tistory.com/229

 

spring initializer를 이용한 springboot 프로젝트 생성

1. 시험환경 ˙ Window ˙ Spring Initializr ˙ Gradle ˙ IntelliJ Community 2. 목적 ˙ Spring Initializer를 이용하여 Spring Boot 프로젝트 패키지를 구성한다. ˙ Spring Initializer를 이용하여 구성된 패키지를 IntelliJ에 임

languagestory.tistory.com

 

    ② Springboot 프로젝트 안에서 react.js 프로젝트를 생성한다.

        - React.js 프로젝트 생성 경로 : [프로젝트홈]/src/main

        - React.js 프로젝트 생성 명령어 : npx  create-react-app  web

 

    ③ React.js "package.json"파일에서 Springboot으로 데이터 전달을 위한 proxy 설정을 한다.

 

    ④ React.js에서 RestAPI 통신을 위한 axios를 설치한다.

        - axios 설치명령어 : npm install axios --save

 

    ⑤ React.js에서 테스트 코드를 작성한다. (RestAPI 송신부)

 

    ⑥ index.js에서 <React.StrictMode> 부분을 주석처리한다.

        - 해당 부분을 주석처리 하지 않으면 RestAPI를 2번 호출한다.

 

    ⑦ Springboot에서 RestAPI 수신부 테스트 코드를 작성하고 프로젝트를 실행한다.

 

    ⑧ React.js 프로젝트를 실행한다.

 

4. 결과

    ˙ Web에 접속하여 React.js와 Springboot 간 연동 여부를 확인한다.

 

    ˙ 현재까지 설정한 내용을 바탕으로 Springboot와 React.js 배포 방법은 아래 포스팅을 참고한다.

        - 참고 : https://languagestory.tistory.com/235

 

Springboot 프로젝트와 React.js 프로젝트 연동 배포

1. 시험환경 ˙ Springboot ˙ React.js ˙ build.gradle 2. 목적 ˙ Springboot 프로젝트에서 React.js 프로젝트를 함께 배포한다. 3. 적용 ① Springboot 프로젝트 안에서 React.js 프로젝트를 생성 및 연동하는 방법은

languagestory.tistory.com

 

반응형
반응형

1. 시험환경

    ˙ EC2, 대상그룹(Target Group)

    ˙ ALB(ELB)

    ˙ Route 53

    ˙ ACM(AWS Certificate Manager)

 

2. 목적

    ˙ ELB의 대상그룹(Target Group)을 생성하고 대상그룹 안에 EC2 인스턴스를 할당하는 방법을 알아보자.

    ˙ ELB 인스턴스를 생성하고 대상그룹(Target Group)을 설정하는 방법을 알아보자.

    ˙ Route 53에 도메인을 등록하고 ELB 인스턴스를 설정하는 방법을 알아보자.

    ˙ Route 53에 TLS(https) 인증서를 적용하는 방법을 알아보자.

    ˙ 아래와 같은 구성으로 개발한 웹서비스를 제공할 수 있는지 알아보자.

서비스 구성도

 

3. 적용

    ① 대상그룹(Target Group) 생성(create) 버튼을 클릭하여 이름 및 서비스 프로토콜/포트를 입력한다.

        - Traget group name : 대상 그룹 이름

        - Protocol, Port : EC2의 서비스 프로토콜 및 포트

 

    ② 대상그룹(Target Group)에 포함할 "running 상태의 EC2" 및 서비스 포트를 선택하고 대상그룹을 생성한다.

        - EC2의 Listening Port는 3000으로 설정하였다. (서비스 마다 다름)

대상그룹(Target Group)에 포함할 EC2(running) 선택
Target Group 생성 결과
설정 부분 (빨간색 박스)

 

    ③ ALB(Application Load Balancer)를 생성한다.

 

    ④ ALB 의 Listener/Forward 규칙을 설정한다.

        - Listener : HTTP / 80

        - Action : 대상그룹(Target Group) 선택

 

설정부분 (빨간색 박스)

 

    ⑤ Route 53에 등록된 도메인과 ELB를 연결한다.

        - 별칭 : 활성화

        - 트래픽 라우팅 대상 : ALB

설정부분 (빨간색 박스)

 

    ⑥ TLS(https)를 적용할 도메인 정보를 입력하여 인증서를 발급한다.

 

    ⑦ 도메인 소유권 인증을 위해 생성된 이름/값을 Route 53에서 CNAME으로 등록한다.

설정 부분 (빨간색 박스)

 

4. 결과

    ˙ DNS 도메인을 입력하여 서비스 되는지 확인한다.

 

반응형
반응형

1. 시험환경

    ˙ Spring Initializr

    ˙ IntelliJ Community

    ˙ SpringBoot, Gradle, MyBatis, MySQL

 

2. 목적

    ˙ Spring Initializr를 이용하여 SpringBoot 프로젝트를 생성한다.

    ˙ MyBatis, MySQL 의존성 패키지를 추가하고 설정하는 방법을 알아보자.

    ˙ MyBatis를 이용하여 DB에 저장된 데이터를 Load하여 사용자에게 보여주는 코드를 작성하자.

 

3. 적용

    MySQL에서 샘플 데이터를 다음과 같이 생성한다.

        - DB 스키마 : crud-template

1
2
3
4
5
6
7
CREATE TABLE `nations` (
  `id` int unsigned NOT NULL,
  `country` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `population` int DEFAULT NULL,
  `language` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
cs

 

     SpringBoot 프로젝트 생성을 위해 Spring Initializr 사이트에 접속한다.

        - URL : https://start.spring.io/

 

     의존성 패키지를 추가하여 프로젝트를 생성한다.

template.zip
0.06MB

 

    IntelliJ에서 프로젝트 폴더를 임포트(import) 하면 프로젝트 빌드(build)가 자동으로 진행된다.

 

     MySQL 및 MyBatis를 설정한다.

        - 경로 : resources/application.properties

1
2
3
4
5
6
7
8
9
10
# MySQL
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/crud-template?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=1q2w3e4r
 
# MyBatis
mybatis.type-aliases-package=com.template.crud.entity
mybatis.mapper-locations=classpath:/mybatis-mapper/**/*.xml
spring.datasource.sql-script-encoding=UTF-8
cs

 

    ⑥ 패키지를 추가하여 각 레이어별 코드를 작성한다.

        - resources/mybatis-mapper/NationsMapper.xml

1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.mybatis.template.repository.NationsMapper">
 
    <select id="findAll" resultType="com.mybatis.template.entity.Nations">
        SELECT * FROM nations
    </select>
 
</mapper>
cs

 

        - com.mybatis.template.entity

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.mybatis.template.entity;
 
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
 
@Getter
@Setter
@ToString
public class Nations {
    private Long id;
    private String country;
    private int population;
    private String language;
}
cs

 

        - com.mybatis.template.repository

1
2
3
4
5
6
7
8
9
10
11
12
13
package com.mybatis.template.repository;
 
import com.mybatis.template.entity.Nations;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
@Repository
@Mapper
public interface NationsMapper {
    List<Nations> findAll();
}
cs

 

        - com.mybatis.template.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.mybatis.template.service;
 
import com.mybatis.template.entity.Nations;
import com.mybatis.template.repository.NationsMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
@RequiredArgsConstructor
public class NationsService {
    private final NationsMapper nationsMapper;
 
    public List<Nations> getAllNations() {
        return nationsMapper.findAll();
    }
}
cs

 

        - com.mybatis.template.controller

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.mybatis.template.controller;
 
import com.mybatis.template.service.NationsService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
@RequiredArgsConstructor
@RestController
public class NationsController {
    private final NationsService nationsService;
 
    @GetMapping("/nations")
    @ResponseBody
    public ResponseEntity getNations() {
        return ResponseEntity.ok(nationsService.getAllNations());
    }
}
 
cs

 

4. 결과

    ˙ 프로젝트를 실행하고 접속하여 DB에 저장된 데이터를 가져 오는지 확인한다.

 

반응형
반응형

1. 시험환경

    ˙ 윈도우

    ˙ IntelliJ Community

 

2. 목적

    ˙ Springboot 프로젝트를 구성 및 최초 실행 시 발생하는 아래 에러를 해결한다.

Execution failed for task ':TemplateApplication.main()'.
> Process 'command 'C:/Program Files/Java/jdk-17.0.5/bin/java.exe'' finished with non-zero exit value 1

 

3. 적용

    ① SpringBoot 프로젝트 구성, IntelliJ 임포트 및 실행하는 방법은 아래 내용을 참고한다.

        - 참고 : 

 

    ② Springboot 프로젝트를 IntelliJ로 최초 실행 시 아래와 같은 에러가 발생할 수 있다.

 

    ③ [File] → [Settings...] 메뉴를 클릭한다.

        - 단축키 : <Ctrl> + <Alt> + <S>

 

    ④ IntelliJ IDEA로 변경한다.

 

반응형
반응형

1. 시험환경

    ˙ GCP(Google Cloud Platform)

    ˙ Kubernetes Cluster

    ˙ 우분투(ubuntu) v22.04

 

2. 목적

    ˙ GCP에서 Kubernetes Cluster 생성하는 절차를 알아보자.

전체 구성도 중 설정 대상 부분(빨간색 박스)

 

3. 적용

    ① GCP(Google Cloud Platform)에 로그인한다.

        - URL : https://cloud.google.com

 

클라우드 컴퓨팅 서비스  |  Google Cloud

데이터 관리, 하이브리드 및 멀티 클라우드, AI와 머신러닝 등 Google의 클라우드 컴퓨팅 서비스로 비즈니스 당면 과제를 해결하세요.

cloud.google.com

 

    ② Kubernetes Engine 클러스터를 만든다.

        - 이름 : kubernetes cluster 이름 입력

 

    ③ 클러스터를 만들기 위한 정보를 입력한다.

        - 클러스터 모드 / 이름 / 영역 or 리전

 

    ④ 버튼 클릭 몇번으로 Google Kubernetes Cluster 생성이 완료되었다.

        - 리눅스 등 로컬 환경에서 Kubernetes(minikube 등)을 직접 구성하는 것에 비해 훨씬 간편하다. (과금은 되지만...)

    ⑤ 생성된 클러스터의 "연결" 버튼을 클릭하면 나타나는 팝업창에서 "명령줄 엑세스"를 확인한다.

        - Local PC 설정 후 Google Cloud CLI를 통해 클러스터에 접속하기 위한 명령어이다.

반응형
반응형

1. 시험환경

    ˙ 우분투(ubuntu) v22.04

    ˙ docker

    ˙ apt-get

 

2. 목적

    ˙ 우분투(ubuntu) 패키지(package) 목록을 업데이트 및 docker.io 패키지 설치한다.

    ˙ docker 설치 가이드에 따라 최신 버전을 설치한다.

    ˙ 각각의 경우 도커(docker) 설치 버전을 확인한다.

 

3. 적용

    ① 패키지를 이용하여 도커(docker)를 설치한다.

        - $ sudo apt get update

        - $ sudo apt install -y docker.io

        - 참고 : https://languagestory.tistory.com/219

 

Ubuntu 환경에서 Jenkins(docker) 설치 및 최초 로그인

1. 시험환경 ˙ 우분투(ubuntu) 리눅스 v22.04 ˙ Jenkins (docker) 2. 목적 ˙ 우분투(ubuntu) 리눅스 환경에서 도커(docker)를 설치(apt install) 한다. ˙ Jenkins Docker 이미지를 실행하고 최초 로그인하는 방법을 알

languagestory.tistory.com

 

    ② docker.io 패키지에 의해 설치된 버전을 확인한다.

 

    ③ 방금 설치한된 도커를 삭제한다.

        - $ sudo apt remove docker.io


     도커(docker) 공식 가이드에 따라 도커(docker)를 설치한다.

        - 참고 : https://languagestory.tistory.com/190

 

우분투(ubuntu) 리눅스 환경에서 docker(도커) 설치하기

1. 시험환경 ˙ 우분투(ubuntu) v20.04 ˙ 도커(docker) 2. 목적 ˙ 우분투(ubuntu) 리눅스 환경에서 도커(docker) 설치하는 방법을 알아보자. 3. 적용 ① docker 공식 사이트에 접속한다. - URL : https://docs.docker.com/c

languagestory.tistory.com

 

    ⑤ 도커 공식 가이드에 의해 설치된 버전을 확인한다.

 

4. 결과

    ˙ 패키지 목록에 반영되는 시간이 오래 걸리기 때문에 도커(docker) 공식 가이드에 따라 최신 버전을 설치하자.

 

반응형

+ Recent posts