💻
Albert's Til
GitHub
  • 매일매일 조금씩 성장하기
    • README
    • CS
      • Network
      • HTTP
        • NO-CACHE
      • 오류 코드
      • ORM 도구
      • Design Pattern
        • CQRS Pattern
          • Event Sourcing and CQRS pattern
        • Builder Pattern
    • DB
      • MySQL
        • Timeline
        • Pagination
        • Index
        • Database Performance Optimization Strategies
        • B+ tree
        • MySQL Connectors VS MySQL Shell(Scripting) VS MySQL Workbench
        • MySQL Storage Engine Architecture
      • Normalization & Denormalization
      • JPA
        • @Transactional
        • Why JPA?
        • About JPA
        • N+1 Issue
        • Index
        • ElementCollection&CollectionTable
        • orphanRemoval
        • CascadeType
        • Use Subselect
        • Dynamic Instance Creation
        • Paging
        • Order
        • Spefication
        • mappedBy
      • MongoDB
        • ObjectId
      • Why MySQL?
      • ACID properties of transactions
      • Between JPA and JDBC
      • Identifiers in Hibernate/JPA
    • Java
      • Jackson de/serialize
      • Collections.singletonList() vs List.of()
      • Manage dependencies in Gradle
      • Logging Level
      • Bean Validation
      • JVM Internals
        • Threads
          • Frame
        • Shared Between Threads
          • Classloader
            • Class Loader Hierarchy
            • Loading Linking Initialization
      • Java Collection Framework
      • Annotation
      • Generic
      • 디미터 법칙
    • Spring
      • Caching
      • Spring Integration Overview
        • ThreadPollTaskExecutor
        • Messaging Bridge
        • Channel Adapter
        • Poller
        • Configuration and @EnableIntegration
        • Message Endpoints
        • Message Channels
      • HATEOAS
      • @Autowired vs Constructor Dependency Injection
      • Spring Security
        • JWT 토큰 사용한 인가
        • OAuth 2 Login
        • OAuth 2 인증
        • 인가
        • 인증
        • PasswordEncoder
      • IoC Container
      • Filter,Interceptor,AOP,Argument Resolver
      • Spring Annotation
      • About Spring
    • Kafka
      • Error Channel
    • Infra
      • Scale Up || Scale Out
      • Docker
        • Dockerfile
        • Docker Hub Deploy
        • Command
      • Cloud 유형
        • Infrastructure as a Service
        • Platform as a Service
        • Software as a Service
      • 무중단 배포
        • 엔진엑스(Nginx)
      • 코드 자동 배포
        • Technical
      • AWS EC2
        • PEM(Privacy Enhanced Mail) 키
      • AWS RDS
      • AWS S3
    • CodeSquad
      • Spring Boot Project 1주차 회고
      • Spring Boot Project 2주차 회고
      • Spirng Boot Project 3주차 회고
      • Spring Boot Project 4주차 회고
    • Foody Moody 프로젝트
      • Query Performance Comparison
      • HeartCount Asynchronous Issue
      • DeferredResult
      • ResponseBodyEmitter
      • SseEmitter (Spring)
      • Server-Sent Events (SSE)
      • 기술 스택 적용 이유
      • NO-CACHE(HTTP)
      • Transactional
    • DDD
      • AggregateId
    • Test
      • RestAssured
    • Coding and Algorithmic Problems
      • 819. Most Common Word
      • 344. Reverse String
      • 125. Valid Palindrome
      • 937. Reorder Data in Log Files
    • Node
      • Async... Await...
      • Custom Transactional Decorator Challenger
    • Python
      • Python Basic Grammar
        • Comments and Input/Output
        • Variable
        • Data type
        • Operations and syntax
        • List,Tuple,Dictionary,Set
        • Function
        • Conditional statement
        • Loop
    • HTML
      • HTML Basic
      • HTML Basic Tags
      • HTML Form Tags
      • HTML Table Tags
    • CSS
      • CSS Basic
      • CSS Practice
Powered by GitBook
On this page
  • CI(Continuous Integration - 지속적인 통합)
  • CI 4가지 규칙
  • 도구
  • 연결 단계
  • 1. Travis CI와 S3을 연동
  • 2. Travis CI와 AWS S3, CodeDeploy 연동
  • Refrence

Was this helpful?

  1. 매일매일 조금씩 성장하기
  2. Infra

코드 자동 배포

Last updated 2 years ago

Was this helpful?

CI(Continuous Integration - 지속적인 통합)

  • 코드 버전 관리를 하는 VCS시스템(Git, SVN 등)에 PUSH가 되면 자종으로 테스트와 빌드가 수행되어 안정적인 배포 파일을 만드는 과정

CI

  • 모든 소스 코드가 있는 단일한 장소를 유지하고 누구든 현재의 소스 코드 및 이전 버전을 얻을 수 있는 곳으로 유지합니다.

  • 빌드 프로세스를 자동화하여 누구나 단일 명령으로 시스템을 소스 코드에서 빌드할 수 있도록 합니다.

  • 테스트를 자동화하여 언제든지 단일 명령으로 시스템에 대한 품질 좋은 테스트 스위트를 실행할 수 있도록 합니다.

  • 누구나 최신의 실행 파일을 얻을 수 있도록 하며, 그 실행 파일이 지금까지의 최상의 실행 파일임을 확신합니다.

도구

  • Travis CI

  • 젠키스

    • 설치형이여서 EC2 인스턴스 하나 더 필요함

  • CodeBuild

    • 유료

연결 단계

1. Travis CI와 S3을 연동

  • CodeDeploy는 저장 기능이 없습니다. 그래서 Travis CI가 빌드한 결과물을 받아서 AWS S3을 저장한다.

  1. AWS Key 발급

    • 일반적으로 AWS 서비스에 외부 서비스가 접근할 수 없습니다. 그러므로 접근 가능한 권한을 가진 key를 생성가하고 TravisCI가 AWS의 S3와 CodeDeploy에 접근할 수 있도록 한다.

  2. Travis CI에 키 등록

    • .travis.yaml 파일에서 등록한 값을 사용할 수 있다. 쉘 스크립트에서 변수를 사용했던 것과 비슷하다.

    • 예 $AWS_ACCESS_KEY

  3. S3 버킷 생성

2. Travis CI와 AWS S3, CodeDeploy 연동

  1. EC2에 IAM 역할 추가하기

    • 역할

      • AWS 서비스에만 할당할 수 있는 권한

      • EC2,CodeDeploy,SQS 등

    • 사용자

      • AWS 서비스 외에 사용할 수 있는 권한

      • 로컬 PC,IDC 서버 등

  2. CodeDeploy 에이전트 설치

# CodeDeploy 에이전트 설치 파일 이동
# AWS CLI를 사용하여 "s3://aws-codedeploy-ap-northeast-2/latest/install" 경로의 파일을 
# "." 현재 디렉토리로 복사하는 명령어
aws s3 cp s3://aws-codedeploy-ap-northeast-2/latest/install . --region ap-northeast02

# install 파일에 실행 권한 추가
chmod +x ./install

# install 파일로 설치
sudo ./install auto

# Agent 실행상태 확인
sudo service codedeploy-agent status

"service"는 Linux 시스템에서 서비스(데몬)를 관리하는 명령어입니다.

service <서비스 이름> <동작>

일반적으로 사용되는 동작은 다음과 같습니다:

  • start: 서비스를 시작합니다.

  • stop: 서비스를 중지합니다.

  • restart: 서비스를 다시 시작합니다.

  • status: 서비스의 상태를 확인합니다.

  • reload: 서비스를 다시 불러옵니다. (설정 파일 변경 사항 적용)

  1. CodeDeploy를 위한 권한 생성

    • CodeDeploy에서 EC2에 접근하려면 권한이 필요합니다.

  2. CodeDeploy 생성

  3. Travis CI,S3,CodeDeploy 연동

Refrence

4가지 규칙
📚
스프링 부트와 AWS로 혼자 구현하는 웹 서비스