Skip to content

working-space/nomad-cafe-server

 
 

Repository files navigation

nomad-cafe-server

8기 7조 디지털 노마드를 위한 주변 카페 알리미(Server)

기술 스택

WAS : Python(Django)
WS : Nginx
WSGI : Gunicorn
DB : MongoDB
Container : Docker
Authentication : AWS Cognito
CI/CD : Github Action

구조

아키텍쳐(기본 구상안)

Django With Gunicorn, Nginx and Docker

아키텍쳐(W Microservices)

예시 NCP 예시

아키텍쳐(W/O Microservices)

예시 NCP 예시

WAS

Setup

Docker

curl -fsSL https://get.docker.com/ | sudo sh

docker-compose

sudo get-apt install docker-compose

django

# 개발 초기 단계의 docker-compose를 활용
# Dockerfile, docker-compose.yml 작성 선 진행
# 위 파일의 코드는 파일 참조
# Service name은 docker-compose 내 service name
# App name은 django에서 사용할 app name

docker-compose run <Service name> django-admin.py startproject <Project name> .
docker-compose run <Service name> django-admin.py startapp <App name> .

nginx 설정 후 Project folder의 settings.py에서 다음 설정 추가

# settings.py

...
ALLOWED_HOSTS = ['web'] # nginx에서 설정한 service name
...

static file을 한 곳에 몰아주는 설정 추가

python

# settings.py

...
STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
...

bash

python3 manage.py collectstatic

nginx

# project folder 하위의 특정 위치(여기선 config/nginx)에 nginx.conf 작성
# docker-compose.yml에 volume에서 nginx.conf 파일이 작성된 위치 mount
# wwwroot는 Dockerfile 작성 시 root 폴더

services:
    ...
    nginx:
        ...
        volumes:
            - .:/wwwroot
            - ./config/nginx:/etc/nginx/conf.d

# static file 관리를 위해 django의 static file이 모인 폴더 위치 설정
# static_root는 django collectstatic 시 설정한 폴더 이름
server {
    ...
    location /static/ {
        alias /wwwroot/static_root/;
    }
}

gunicorn

# requirements.txt에 gunicorn 추가 필수
# 구동은 docker-compose.yml에 작성

services:
    ...
    web: # Service name
        ...
        command: gunicorn was.wsgi:application --bind 0.0.0.0:8000 # was는 django의 project name

참조 링크

Django RestAPI Quickstart

Django 프로젝트 배포(with docker, nginx, gunicorn)

Django 설치 가이드-1

Django 설치 가이드-2

Django with AWS Cognito

NCP 레퍼런스 아키텍쳐

Github action 정리

Static file 처리

Testcode 작성

About

8기 7조 디지털 노마드를 위한 주변 카페 알리미(Server)

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 48.7%
  • CSS 46.3%
  • Python 4.9%
  • Dockerfile 0.1%