-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 2.95 KB
/
aws.yml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
# Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시하는 과정
build-docker-image:
runs-on: ubuntu-latest
environment: video-share
steps:
- uses: actions/checkout@v3
# 1. Java 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# 2. Spring Boot 애플리케이션 빌드
- name: Build with Gradle
run: |
touch src/main/resources/application-oauth.properties
touch src/main/resources/application-prod.properties
touch src/main/resources/application.properties
echo "${{ secrets.APPLICATION_PROD }}" > src/main/resources/application-prod.properties
echo "${{ secrets.APPLICATION_OAUTH }}" > src/main/resources/application-oauth.properties
echo "${{ secrets.APPLICATION_PROPERTIES }}" > src/main/resources/application.properties
cat src/main/resources/application-prod.properties
chmod +x gradlew
./gradlew clean build
ls
pwd
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/streaming .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/streaming:latest
cd live-streaming
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nginx-rtmp:ssl .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/nginx-rtmp:ssl
- name: Transfer files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: .
target: app
- name: SSH into EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo apt-get update
sudo apt-get install ec2-instance-connect
sudo apt-get install docker.io -y
sudo apt-get install docker-compose -y
sudo apt-get install jq -y
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
DESTINATION=/usr/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION
sudo systemctl start docker
sudo docker pull van133/streaming
sudo docker pull van133/nginx-rtmp:ssl
sudo docker-compose build
#sudo sh ./init-letsencrypt.sh
sudo docker-compose up -d