Skip to content

Commit

Permalink
doul docs: docz create
Browse files Browse the repository at this point in the history
  • Loading branch information
sgd122 committed May 21, 2020
0 parents commit b62c671
Show file tree
Hide file tree
Showing 105 changed files with 17,323 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.docz
node_modules
.DS_Store
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# TODO: 참조하여 개선하기
# FROM gatsbyjs/gatsby:onbuild as build
# FROM gatsbyjs/gatsby
# COPY --from=build /app/public /pub

FROM node:10 AS builder

WORKDIR /proj
COPY package.json /proj
COPY yarn.lock /proj
RUN yarn

COPY . /proj
RUN yarn build

FROM nginx:1.17-alpine

# nginx의 기본 설정을 삭제하고 앱에서 설정한 파일을 복사
RUN rm -rf /etc/nginx/conf.d
COPY conf/nginx.conf /etc/nginx/nginx.conf

# 위에서 생성한 앱의 빌드산출물을 nginx의 샘플 앱이 사용하던 폴더로 이동
COPY --from=builder /proj/.docz/dist /usr/share/nginx/html

EXPOSE 80
CMD [ "nginx", "-g", "daemon off;" ]

41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Basic Docz example

## Using `create-docz-app`

```sh
npx create-docz-app docz-app-basic
# or
yarn create docz-app docz-app-basic
```

## Download manually

```sh
curl https://codeload.github.com/doczjs/docz/tar.gz/master | tar -xz --strip=2 docz-master/examples/basic
mv basic docz-basic-example
cd docz-basic-example
```

## Setup

```sh
yarn # npm i
```

## Run

```sh
yarn dev # npm run dev
```

## Build

```sh
yarn build # npm run build
```

## Serve built app

```sh
yarn serve # npm run serve
```
40 changes: 40 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

keepalive_timeout 65;

#gzip on;

server {
listen 80;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}
}
}

50 changes: 50 additions & 0 deletions doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export default {
title: "도울정보기술 개발문서 서비스",
// base: "/docz/"
// files: ["**/*.{mdx,markdown,png}"],
ignore: ["README.md"],
menu: [
"Getting Started",
// "Architectures",
// "Deployments",
// "Components",
// "Setup",
{ name: "Architectures", menu: ["Overview", "Backend", "Frontend"] },
{
name: "Development Setup",
menu: [
"Develop Guide",
"Proxy Server Squid",
"Package Manager",
"Docker",
"Django",
"React",
"GitLab",
"GitLab-CI",
"CI/CD Pipeline",
"Visual Studio Code",
],
},
{ name: "Development", menu: ["Docker", "Django", "React", "개발표준"] },
{
name: "Server Settings",
menu: ["Container", "Nexus3", "Develop & Production"],
},
"Components",
],
themeConfig: {
colors: {
text: "#333",
background: "#fff",
primary: "tomato",
headers: {
bg: "tomato",
},
},
fonts: {
body: "system-ui, sans-serif",
heading: '"Avenir Next", sans-serif',
monospace: "D2Coding, Menlo, monospace",
},
},
};
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "doul-dev-docs",
"version": "2.0.0",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build",
"serve": "docz serve"
},
"dependencies": {
"docz": "latest",
"prop-types": "^15.7.2",
"react": "^16.11.0",
"react-dom": "^16.11.0"
}
}
52 changes: 52 additions & 0 deletions src/architectures/00-overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: Overview
menu: Architectures
route: /architectures/overview
---

## Load Balancer

단일 서비스에 대한 단일 진입점입니다. Nginx 웹서버를 Linux 물리머신에 Native 설치하기를 권장합니다.

1. Nginx 웹서버로 Reverse Proxy를 구축하여, 각 서비스에 대한 요청을 전달해주는 역할을 합니다. Nginx 외에도 필요에 의해 Reverse Proxy 역할을 하는 다른 서비스를 사용할 수도 있습니다. (예: Kong, HAProxy 등)
2. 내부 각 웹서비스가 어떤 기술로 개발이 되었는 지, 어떤 방식으로 서비스가 관리되고 있는 지에 대해서는 Load Balancer 입장에서는 Don’t care 입니다. 내부 웹서비스는 약속된 포트로 웹서비스만 제공하면 됩니다.
3. 내부 각 웹서비스를 위해 별도의 도메인을 할당하는 것을 추천합니다. Nginx 단에서 도메인을 통해 전달할 웹서비스를 결정하는 것이 Nginx 설정을 보다 간단하게 가져갈 수 있기 때문입니다. (예: 장고용(api.도메인.com), 리액트(도메인.com), File Server(임의도메인))
4. 외부 서비스 프로토콜은 필히 https를 사용하여야 하며, 내부에서는 http 프로토콜을 사용합니다.
5. 일반적으로 OS단에서 file open 최대갯수제한이 1024 정도로 잡혀있습니다. 허용할 수 있는 소켓 연결제한이 너무 작기에 65535값으로 최대한 늘려줍니다.

---

## Container Orchestration

조직의 인프라에 맞춰 다양한 Container Orchestration 툴을 선택해서 운영합니다. Kubernetes(이하 k8s)가 가장 유명하고 널리 사용되고는 있지만, k8s 인프라를 직접 구성하고 운영하는 것은 아주 많은 인력과 경험을 요구합니다. k8s를 사용코자 한다면, 유명 클라우드 벤더 (Microsoft, Azure, Google)의 서비스형 k8s를 사용하기를 권장합니다. k8s는 수십만~수십억개 이상의 컨테이너를 관리할 수 있습니다.
수십개의 컨테이너를 운영하는 경우라면 Docker Swarm이나 k3s를 활용할 수 있습니다. 본 문서에서는 Docker Swarm 기준으로 가이드를 진행합니다. K8s 인프라를 사용하더라도 컨테이너를 관리해주는 주체만 변경될 뿐, 기본적인 아키텍처는 변하지 않습니다.

---

## File Server

장고 API Server는 단일 인스턴스로 구동되는 것이 아니라, 서비스 상황에 따라 멀티 인스턴스로 서비스될 수 있으며, 그 인스턴스들은 여러 VM에 걸쳐서 존재할 수 있습니다. 그렇기에 멀티 인스턴스에 의해 Read/Write할 수 있으며, 동시에 웹서버의 기능도 가진 File Server가 필요해지게 됩니다. 파일 Read/Write를 위한 인터페이스로 NFS, FTP, SFTP 등이 가능합니다만, 이 중에 보안에 유리하고 유연하며 신뢰성있는 인터페이스로 SFTP를 채용토록 합니다.

1. SFTP 지원을 위해 SSH 서버 설치가 필요합니다.
- SSH 서버 운영이 어렵다면 NFS 서버를 설정하고, 관련 설정을 Django Container 운영 시에 환경변수를 통한 설정이 필요합니다.
- NFS은 파일 시스템 인터페이스이기 때문에 장고에서 기본 지원하고 있으며, SFTP의 경우 django-storages 라이브러리를 통해 지원하고 있습니다.
2. HTTP 파일 서빙을 위해 nginx 서버 설치가 필요합니다.
3. OS는 윈도우/맥/리눅스 모두 가능합니다만, Ubuntu 리눅스 서버가 최신 팩키지가 빠르게 지원되기 때문에, 보다 쾌적하게 서버를 운영할 수 있습니다.
4. 안정적인 File Server 서비스를 위해 2~3중화 백업이 필요할 수도 있습니다. 이를 위해 별도의 정적 파일 저장소 솔루션이 필요합니다.

---

## Database Server

Container와 무관하게 조직에서 데이터베이스를 설치/운영하는 방식으로 데이터베이스를 셋업하고, 장고 API 서버에서 접근할 수 있도록 네트워크 설정을 맞춰줍니다.

1. 장고에서는 RDBMS를 장고 기본에서 지원하고 있습니다. 1개 이상의 RDBMS를 하나의 장고 프로젝트와 연동할 수 있습니다. 다수의 DB를 지원할려면 장고 프로젝트에서 DB Router를 구현하여야만 합니다.

---

## Cache Server

Container와 무관하게 조직에서 데이터베이스를 설치/운영하는 방식으로 캐시 서버를 셋업하고, 장고 API 서버에서 접근할 수 있도록 네트워크 설정을 맞춰줍니다. 대표적인 캐시 서버로는 Memcached와 Redis가 있습니다. 프로젝트 성격에 따라 선택합니다.

1. Memcached : 메모리 기반 단순 Key/Value 캐시서버. 일반적인 목적의 캐시에 적합합니다.
2. Redis : Memcached보다 기능이 많은 캐시서버이자 NoSQL 서버. Memcached에 비해 메모리를 많이 먹지만, 다양한 데이터 타입과 API를 지원합니다.
Loading

0 comments on commit b62c671

Please sign in to comment.