Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #8

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/algofi-compilec-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CompileC Build and Push

on:
push:
branches:
- develop
# develop 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-compile-c/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-compile-c
# Dockerfile이 있는 위치입니다.
file: ./algofi-compile-c/Dockerfile
# Dockerfile의 경로입니다.
push: true
# 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-compile-c:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64
43 changes: 43 additions & 0 deletions .github/workflows/algofi-compilejava-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CompileJava Build and Push

on:
push:
branches:
- develop
# develop 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-compile-java/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-compile-java
# Dockerfile이 있는 위치입니다.
file: ./algofi-compile-java/Dockerfile
# Dockerfile의 경로입니다.
push: true
# 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-compile-java:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64
43 changes: 43 additions & 0 deletions .github/workflows/algofi-compilejavascript-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CompileJavascript Build and Push

on:
push:
branches:
- develop
# develop 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-compile-javascript/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-compile-javascript
# Dockerfile이 있는 위치입니다.
file: ./algofi-compile-javascript/Dockerfile
# Dockerfile의 경로입니다.
push: true
# 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-compile-javascript:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64
43 changes: 43 additions & 0 deletions .github/workflows/algofi-compilepython-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CompilePython Build and Push

on:
push:
branches:
- develop
# develop 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-compile-python/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-compile-python
# Dockerfile이 있는 위치입니다.
file: ./algofi-compile-python/Dockerfile
# Dockerfile의 경로입니다.
push: true
# 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-compile-python:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64
43 changes: 43 additions & 0 deletions .github/workflows/algofi-core-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Core Build and Push

on:
push:
branches:
- develop
# 08-cicd 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-core/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-core
# Dockerfile이 있는 위치입니다.
file: ./algofi-core/Dockerfile
# Dockerfile의 경로입니다.
push: true # 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-core:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64

44 changes: 44 additions & 0 deletions .github/workflows/algofi-mysql-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: MySQL Build and Push

on:
push:
branches:
- develop
# develop 브랜치에 push될 때 워크플로우가 실행됩니다.
paths:
- 'algofi-mysql/**'

jobs:
build-and-push:
runs-on: ubuntu-latest
# 가장 최신의 Ubuntu 러너를 사용합니다.

steps:
- name: Checkout Repository
uses: actions/checkout@v2
# 현재 리포지토리를 체크아웃합니다.

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Docker Buildx를 설정합니다.

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# GitHub Secret에서 Docker Hub 사용자 이름을 가져옵니다.
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GitHub Secret에서 Docker Hub 액세스 토큰을 가져옵니다.

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: ./algofi-mysql
# Dockerfile이 있는 위치입니다.
file: ./algofi-mysql/Dockerfile
# Dockerfile의 경로입니다.
push: true
# 이미지를 레지스트리에 푸시합니다.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/algofi-mysql:${{ github.sha }}
platforms: linux/amd64,linux/arm64,windows/amd64

8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/algorithm-fighter-back.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/material_theme_project_new.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
# algorithm-fighter-back
# Algorithm-Fighter

## 개요
Algorithm-Fighter 프로젝트의 백엔드 초기 개발환경을 설명합니다.

## 프로젝트 구조
벡엔드 프로젝트 하위는 각 API서버 프로젝트(컨테이너 기반으로 구성됨)로 나눠져있습니다.
API서버는 아키텍처 구조(6.5.(수) 기준)을 따르고 있으며 각 프로젝트는 다음과 같습니다.
- algofi-core : 인증, 사용자 관리, 문제 관리, 채점, 랭킹 등의 핵심 기능을 제공하는 코어 서버
- algofi-mysql : MySQL 데이터베이스 서버
- algofi-compile-c : C 컴파일 서버
- algofi-compile-java : Java 컴파일 서버
- algofi-compile-javascript : JavaScript 컴파일 서버
- algofi-compile-python : Python 컴파일 서버

## 사전 준비
프로젝트를 개발하기 전 사전 준비 작업입니다.
- 본인 PC에 Docker 설치(https://www.docker.com/products/docker-desktop/)
- 개발IDE에 Docker 플러그인 설치(예: IntelliJ IDE의 Docker 플러그인)
- Docker Desktop 실행

## 빌드 및 테스트
크게 Local 빌드와 Docker 빌드로 나눠집니다.
### Local 빌드
평소처럼 본인 PC에서 개발하듯이 하면 됩니다.

### Docker 빌드
1. Docker Desktop 실행
2. 각 프로젝트의 Dockerfile을 이용하여 Docker 이미지를 빌드합니다.
```bash
docker buildx build -t algofi-core .
docker buildx build -t algofi-mysql .
docker buildx build -t algofi-compile-c .
docker buildx build -t algofi-compile-java .
docker buildx build -t algofi-compile-javascript .
docker buildx build -t algofi-compile-python .
```
3. 빌드된 이미지를 Docker 컨테이너로 실행합니다.
```bash
docker run -d -p 8080:8080 algofi-core
docker run -d -p 3306:3306 algofi-mysql
docker run -d -p 9001:9001 algofi-compile-c
docker run -d -p 9002:9002 algofi-compile-java
docker run -d -p 9003:9003 algofi-compile-javascript
docker run -d -p 9004:9004 algofi-compile-python
```
4. 각 컨테이너의 포트번호를 확인하고, API 서버에 접속합니다.(localhost:포트번호)
- algofi-core : 8080
- algofi-mysql : 3306
- algofi-compile-c : 9001
- algofi-compile-java : 9002
- algofi-compile-javascript : 9003
- algofi-compile-python : 9004

5. 테스트 확인 이후 컨테이너를 삭제합니다.
```bash
docker rm -f $(docker ps -a -q)
```

## CI/CD 관점에서 완료사항
- 서버에 대한 샘플 dockerfile(core서버 기준) 작성완료(각 프로젝트의 Dockerfile)
- 각 컨테이너 포트번호 설정 및 통신여부 확인
- docker-compose를 통한 여러 컨테이너 동시 실행 확인
- github actions를 활용하기 위한 CI 설정값 구성(.github/workflows/ 하위 yml 파일들)

## 백엔드팀에서 앞으로 해야할 일
- MySQL서버, Compile서버에 맞는 Dockerfile 재구성
- 요구사항에 따른 기능 구현
- 서버에 대한 테스트 코드 작성
- CD 파이프라인 구성(최종적으로 크램폴린까지)
Loading
Loading