Ryu
  • 👩🏻‍💻 Ryu / software_engineer
  • ✨Resume
  • Python3
    • Python3 가상환경 설정하기
      • Python3 vs Python2
      • Pyenv
      • Venv
      • Pip
    • Flask
      • Flask 설치하기
      • API Server 만들기
    • REST API
    • Command Line 활용하기
    • Module 사용하기
      • Pickle - 자료형을 파일로 저장할 때
    • MongoDB connection
      • Pymongo
    • WSGI
      • 💡WSGI 가 필요한 이유
      • Web Server / WSGI / Middleware / Application 구조
      • WSGI Middleware 종류
      • Gunicorn
        • Gunicorn vs Uwsgi
    • Dockerize
      • 💡Dockerize 가 필요한 이유
      • 1. Create Dockerfile
        • Gunicorn 으로 nginx 와 app 연결하기
    • Kubernetes 로 배포하기
      • 💡Kubernetes 가 필요한 이유
      • Helm 사용하기
      • Helm 으로 k8s 에 앱 배포하기
  • Open Tracing (정리중)
    • Open Tracing 이란 무엇인가
    • Python OpenTracing Example
    • Jaeger, Jaeger UI
    • Python Jaeger Tutorial
    • Zipkin 알아보기
    • Jaeger-client 리스팅
  • Microservice Architecture
    • Netflix의 MSA 컨셉
      • ⚡️ MSA 를 도입할때 고려해야할 점들
  • Paper
    • Dynamo: Amazon’s Highly Available Key-value Store
      • 1. Introduction
      • 2. Background
      • 3. Related Work
        • Related Paper) Pastry, Chord
        • Byzantine Fault Tolerance
      • 4. System Architecture
        • 4.1 System Interface
        • 4.2 Partitioning
        • 4.3 Replication
        • Hash Function
  • Frontend
    • CommonJS 와 AMD
    • RequireJS
    • WebSocket
      • WebSocket vs Socket.io
      • polling vs long polling vs streaming
    • Vue.js
      • Vue.js 에서 WebSocket 사용하기
      • [프로젝트] Vue, Vuex, AntDesignVue 로 운영툴 만들기
    • React x Redux 로 프로젝트 만들기
      • 0. React, Redux 를 선택한 이유
      • 1. 프로젝트 생성하고 Webpack4 적용하기
      • 2. React 와 ReactDOM 적용하기
      • 3. Material UI 적용하기
  • Data Engineering
    • Spark
      • Spark 이란?
      • 각 데몬의 역할 Driver, Master, Worker
      • 장단점 / 함께사용하는 툴 / 사용 사례
  • Service Mesh (정리중)
    • RPC
    • gRPC - Python Server 만들기
      • step 2.
Powered by GitBook
On this page
  • Dockerfile 생성하기 🐳
  • 로컬에서 확인하기
  • Dockerfile Command 상세 📄

Was this helpful?

  1. Python3
  2. Dockerize

1. Create Dockerfile

Dockerfile 생성하기

Dockerfile 생성하기 🐳

/Dockerfile

FROM centos/python-36-centos7

# timezone
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

# path configs
ENV DEPLOY_HOME=/deploy
RUN mkdir -p $DEPLOY_HOME/
WORKDIR $DEPLOY_HOME

# python packages
ADD . $DEPLOY_HOME/
RUN pip install --upgrade -r requirements.txt

ENV PORT=8000 \
    NUM_WORKERS=4

ENTRYPOINT ["./docker-entry.sh"]

./docker-entry.sh

exec gunicorn server:app \
  --worker-class gunicorn.workers.ggevent.GeventWorker \
  --bind 0.0.0.0:$PORT "$@"

로컬에서 확인하기

Build Dockerfile

$ docker build -t {repository_name}

Run Docker Image

$ docker run -p 9000:8000 {repository_name}

Test API call

$ curl -X GET http://localhost:9000/

Example:

-

Dockerfile Command 상세 📄

  • centos 에 올라간 python 이미지를 받아옵니다.

FROM centos/python-36-centos7
  • 이후 현재 경로에 있는 폴더를 복사하고

ADD . $DEPLOY_HOME/
  • 현재 프로젝트에서 사용하고 있는 Python Packages 를 설치한 뒤

RUN pip install --upgrade -r requirements.txt
  • PORT 와 띄울 Worker 갯수를 환경변수로 셋팅하고, Entry Point 로 ./docker-entry.sh 를 지정해줍니다.

ENV PORT=8000 \
    NUM_WORKERS=4
    
ENTRYPOINT ["./docker-entry.sh"]
PreviousDockerize 가 필요한 이유NextGunicorn 으로 nginx 와 app 연결하기

Last updated 6 years ago

Was this helpful?