Skip to content

Commit

Permalink
Merge pull request #256 from tukcomCD2024/develop_back
Browse files Browse the repository at this point in the history
develop back to master
  • Loading branch information
seokho-1116 authored Mar 15, 2024
2 parents c8602df + 624f154 commit 6782c9d
Show file tree
Hide file tree
Showing 276 changed files with 3,733 additions and 1,844 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/animation-application-ci-cd-flow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: animation-application-ci/cd

on:
push:
branches:
- develop_back_animation
- 'hotfix/[0-9a-zA-z]+-B-animation-#[0-9a-zA-z]+'

jobs:
deploy-animation:
name: animation application deploy
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend/AnimatedDrawings

permissions:
id-token: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.CI_PAT }}

- name: move yaml files
run: |
mkdir -p ./config/yaml
cp -r ../core/src/main/resources/config ./application/config/yaml
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_ECR_ANIMATED_DRAWINGS_NAME }}
tags: |
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./backend/AnimatedDrawings
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false

- name: Get Github action IP
id: ip
uses: haythem/[email protected]

- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Connect ec2 and Run Docker Container
uses: appleboy/[email protected]
env:
AWS_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
host: ${{ secrets.SSH_ANIMATED_DRAWINGS_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_CORE_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker ps -q --filter "name=animated_drawings" | xargs -r docker stop
docker ps -aq --filter "name=animated_drawings" | xargs -r docker rm
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
docker pull ${{ steps.meta.outputs.tags }}
docker image prune -f
docker run -d -p 5555:5555 -p 9001:9001 --name animated_drawings -e ENVIRONMENT='dev' ${{ steps.meta.outputs.tags }}
- name: Remove Github Actions IP from security group
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- uses: sarisia/actions-status-discord@v1
if: success()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
content: "여러분 <@384742716933668867> <@1084774841460215839> <@545902166842408960> <@1081452554149449748>\n 배포 완료했습니다!!"
title: "애니메이션 서버 배포 완료 알림"
description: "백엔드 애니메이션 개발 브랜치에 깃허브 액션으로 배포 완료"
image: ${{ secrets.EMBED_IMAGE }}
color: 0x0000ff
url: "https://github.com/tukcomCD2024/DroidBlossom/actions"
username: GitHub Actions Bot
avatar_url: ${{ secrets.AVATAR_URL }}
File renamed without changes.
118 changes: 118 additions & 0 deletions .github/workflows/notification-application-ci-cd-flow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: ci/cd

on:
push:
branches:
- develop_back_notification
- 'hotfix/[0-9a-zA-z]+-B-notification-#[0-9a-zA-z]+'

jobs:
deploy-notification:
name: notification application deploy
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend/notification

permissions:
id-token: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.CI_PAT }}

- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'liberica'
cache: gradle

- name: grant execute permission for gradlew
run: chmod +x ./gradlew

- name: build gradle
run: ./gradlew clean build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_ECR_NOTIFICATION_REPOSITORY_NAME }}
tags: |
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./backend/notification
platforms: linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false

- name: Get Github action IP
id: ip
uses: haythem/[email protected]

- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Connect ec2 and Run Docker Container
uses: appleboy/[email protected]
env:
AWS_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
host: ${{ secrets.SSH_NOTIFICATION_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_CORE_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker ps -q --filter "name=notification" | xargs -r docker stop
docker ps -aq --filter "name=notification" | xargs -r docker rm
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
docker pull ${{ steps.meta.outputs.tags }}
docker run -d -p 8080:8080 --name notification --network test_backend ${{ steps.meta.outputs.tags }}
- name: Remove Github Actions IP from security group
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- uses: sarisia/actions-status-discord@v1
if: success()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
content: "여러분 <@384742716933668867> <@1084774841460215839> <@545902166842408960> <@1081452554149449748>\n 배포 완료했습니다!!"
title: "알림 서버 배포 완료 알림"
description: "백엔드 알림 개발 브랜치에 깃허브 액션으로 배포 완료"
image: ${{ secrets.EMBED_IMAGE }}
color: 0x0000ff
url: "https://github.com/tukcomCD2024/DroidBlossom/actions"
username: GitHub Actions Bot
avatar_url: ${{ secrets.AVATAR_URL }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "backend/core/src/main/resources/config"]
path = backend/core/src/main/resources/config
url = https://github.com/seokho-1116/DroidBlossom-config.git
[submodule "backend/notification/src/main/resources/config"]
path = backend/notification/src/main/resources/config
url = https://github.com/seokho-1116/DroidBlossom-config-notification.git
19 changes: 10 additions & 9 deletions backend/AnimatedDrawings/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
FROM continuumio/miniconda3:latest
FROM continuumio/miniconda3

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY . /app
RUN mkdir -p /app/application/capsuleSkin
WORKDIR /app

RUN conda create --name animated_drawings python=3.8.13

SHELL ["conda", "run", "-n", "animated_drawings", "/bin/bash", "-c"]

# Install gcc and python3-dev
RUN apt-get update && apt-get install -y gcc python3-dev

# Install psutil
RUN pip install -e .

RUN apt-get update && apt-get install -y g++ default-jdk
RUN apt-get update && apt-get install -y gcc python3-dev supervisor

RUN apt-get install -y libosmesa6-dev freeglut3-dev && \
apt-get install -y libglfw3-dev libgles2-mesa-dev && \
apt-get install -y libosmesa6

RUN export PYOPENGL_PLATFORM=osmesa
COPY supervisord.conf /etc/supervisor/supervisord.conf

# Install psutil
RUN pip install -e .

WORKDIR /app/application

CMD ["conda", "run", "-n", "animated_drawings", "python3", "-m", "flask", "run", "--host=0.0.0.0"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import numpy.typing as npt
import cv2
from OpenGL import GL
from tqdm import tqdm

from animated_drawings.controller.controller import Controller
from animated_drawings.model.scene import Scene
Expand Down Expand Up @@ -50,8 +49,6 @@ def __init__(self, cfg: ControllerConfig, scene: Scene, view: View) -> None:

self.frame_data = np.empty([self.video_height, self.video_width, 4], dtype='uint8') # 4 for RGBA

self.progress_bar = tqdm(total=self.frames_left_to_render)

def _set_frames_left_to_render_and_delta_t(self) -> None:
"""
Based upon the animated drawings within the scene, computes maximum number of frames in a BVH.
Expand Down Expand Up @@ -104,7 +101,6 @@ def _finish_run_loop_iteration(self) -> None:
# update our counts and progress_bar
self.frames_left_to_render -= 1
self.frames_rendered += 1
self.progress_bar.update(1)

def _cleanup_after_run_loop(self) -> None:
logging.info(f'Rendered {self.frames_rendered} frames in {time.time()-self.run_loop_start_time} seconds.')
Expand Down
39 changes: 0 additions & 39 deletions backend/AnimatedDrawings/app.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 6782c9d

Please sign in to comment.