woowacourse / service-apply

우아한테크코스 지원부터 최종 합격까지 모든 과정을 관리한다.
530 stars 100 forks source link

개발 서버를 배포한다. #115

Open woowahan-pjs opened 4 years ago

woowahan-pjs commented 4 years ago

Administrator

./gradlew clean build -Pvaadin.productionMode
nohup java -jar ./build/libs/apply-0.0.1-SNAPSHOT.jar &

Frontend

cd frontend/
npm install
npm run serve &

If you're using Ubuntu 18.4 make sure you add the node 10 repository

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt -y install nodejs make gcc g++

https://github.com/npm/cli/issues/681

LTTTTTE commented 4 years ago

s3 정적 웹사이트 호스팅 (현재 archive front배포방식) https://docs.aws.amazon.com/ko_kr/AmazonS3/latest/dev/EnableWebsiteHosting.html 올린모습 http://apply-web-test.s3-website.ap-northeast-2.amazonaws.com/ +클라우드프론트 https://ddqva2t3vv9sl.cloudfront.net/

woowahan-pjs commented 4 years ago
woowahan-pjs commented 4 years ago

AWS EC2 Ubuntu 18.04

sudo apt update
sudo apt install default-jre
sudo apt install default-jdk
sudo apt install ruby
sudo apt install awscli
cd /home/ubuntu/ 
sudo aws configure
AWS Access Key ID [None]: 
AWS Secret Access Key [None]: 
Default region name [None]: ap-northeast-2
Default output format [None]: json
wget https://aws-codedeploy-ap-northeast-2.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
woowahan-pjs commented 4 years ago
woowahan-pjs commented 4 years ago

CodeDeploy 로그 데이터 보기 https://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/deployments-view-logs.html

woowahan-pjs commented 4 years ago

문제

Elastic Beanstalk 생성 시 오류가 발생한다.

Creating load balancer failed Reason: Default VPC not found (Service: AmazonElasticLoadBalancing; Status Code: 409; Error Code: InvalidConfigurationRequest; Request ID: 5bd22acf-114f-4a4c-ae4d-1e0e5ec2c672; Proxy: null)

Stack named 'awseb-e-pmbdem9uid-stack' aborted operation. Current state: 'CREATE_FAILED' Reason: The following resource(s) failed to create: [AWSEBLoadBalancer].

해결 방법

기본 VPC를 생성한다. https://docs.aws.amazon.com/ko_kr/vpc/latest/userguide/default-vpc.html#create-default-vpc

woowahan-pjs commented 4 years ago

문제

Beanstalk 환경의 EC2 인스턴스에서 /var/log/eb-activity.log/var/log/eb-commandprocessor.log가 보이지 않는다. Elastic Beanstalk 환경에서 Amazon EC2 인스턴스의 로그 보기

woowahan-pjs commented 4 years ago

buildspec.yml

version: 0.2
phases:
  build:
    commands:
      - echo Build Starting on `date`
      - chmod +x ./gradlew
      - ./gradlew clean build -Pvaadin.productionMode -x test
  post_build:
    commands:
      - echo $(basename ./build/libs/*.jar)
      - pwd
artifacts:
  files:
    - ./build/libs/*.jar
    - ./appspec.yml
    - ./scripts/**
  discard-paths: yes
cache:
  paths:
    - /root/.gradle/caches/**/*
    - '**/node_modules/**/*'

appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu/build/
permissions:
  - object: /
    pattern: "**"
    owner: ubuntu
    group: ubuntu
hooks:
  AfterInstall:
    - location: deploy.sh
      timeout: 60
      runas: ubuntu

deploy.sh

#!/bin/bash
BUILD_PATH=$(ls /home/ubuntu/build/*.jar)
JAR_NAME=$(basename $BUILD_PATH)

CURRENT_PID=$(pgrep -f $JAR_NAME)

if [ -z $CURRENT_PID ]
then
  sleep 1
else
  kill -15 $CURRENT_PID
  sleep 5
fi

DEPLOY_PATH=/home/ubuntu/
cp $BUILD_PATH $DEPLOY_PATH
cd $DEPLOY_PATH

DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME
nohup java -jar $DEPLOY_JAR > /dev/null 2> /dev/null < /dev/null &
woowahan-pjs commented 4 years ago

참고 자료

https://java.ihoney.pe.kr/475

woowahan-pjs commented 4 years ago
  1. S3
  2. CloudFront
    • Web
    • Origin Domain Name: S3 정적 웹 사이트 엔드포인트
    • Default Root Object: index.html
  3. Elastic Beanstalk
  4. CodePipeline
  5. CodeBuild
woowahan-pjs commented 4 years ago
woowahan-pjs commented 4 years ago

121.165.253.64/27 (사무실), 121.165.253.192/27 (VPN), 58.236.10.83 (VPN)

e.g. 121.165.253.64/27

01111001.10100101.11111101.01000000
11111111.11111111.11111111.11100000