GithubHelp home page GithubHelp logo

eb-docker-deploy's Introduction

EB Docker deploy

Elastic Beanstalk에 Nginx-uWSGI-Django로 구성된 Docker 이미지를 배포합니다.

Requirements

공통사항

  • Python (3.6)
  • .secrets/의 JSON파일 작성 (아래의 .secrets항목 참조)
  • (선택사항) Docker로 실행할 경우, Docker설치 필요

AWS환경

  • Python (3.6)
  • S3 Bucket, 해당 Bucket을 사용할 수 있는 IAM User의 AWS AccessKey, SecretAccessKey
  • RDS Database(보안 그룹 허용 필요), 해당 Database를 사용할 수 있는 RDS의 User, Password

Installation (Django runserver)

로컬 환경

pip install -r .requirements/dev.txt
python manage.py runserver

AWS 환경

export DJANGO_SETTINGS_MODULE=config.settings.dev
pip install -r .requirements/dev.txt
python manage.py runserver

배포 환경

export DJANGO_SETTINGS_MODULE=config.settings.production
pip install -r .requirements/dev.txt
python manage.py runserver

Installation (Docker)

로컬 환경

localhost:8000 에서 확인

docker build -t eb-docker:local -f Dockerfile.local
docker run --rm -it 8000:80 eb-docker:local

AWS 환경 (개발 모드)

docker build -t eb-docker:dev -f Dockerfile.dev
docker run --rm -it 8000:80 eb-docker:dev

AWS 환경 (배포 모드)

docker build -t eb-docker:production -f Dockerfile.production
docker run --rm -it 8000:80 eb-docker:production

DockerHub 관련

apt, pip관련 내용을 미리 빌드해서 DockerHub 저장소에 업로드

docker build -t eb-docker:base -f Dockerfile.base
docker tag eb-docker:base <자신의 사용자명>/<저장소명>:base
docker push <사용자명>/<저장소명>:base

이후 ElasticBeanstalk을 사용한 배포 시, 해당 이미지를 사용

FROM    <사용자명/<저장소명>:base
...
...

Deploy

.deploy.sh파일을 사용

./deploy.sh

.secrets

.secrets/base.json

    {
      "SECRET_KEY": "<Django secret key>",
      "RAVEN_CONFIG": {
        "dsn": "https://<Sentry secret key>@sentry.io/300780",
        "release": "raven.fetch_git_sha(os.path.abspath(os.pardir))"
      },
      "SUPERUSER_USERNAME": "<Default superuser username>",
      "SUPERUSER_PASSWORD": "<Default superuser password>",
      "SUPERUSER_EMAIL": "<Default superuser email>",

      "AWS_ACCESS_KEY_ID": "<AWS access key (Permission: S3)>",
      "AWS_SECRET_ACCESS_KEY": "<AWS secret access key>",
      "AWS_STORAGE_BUCKET_NAME": "<AWS S3 Bucket name>",
      "AWS_S3_REGION_NAME": "<AWS Bucket region",
      "AWS_S3_SIGNATURE_VERSION": "s3v4",
      "AWS_DEFAULT_ACL": "private"
    }

.secrest/dev.json, .secrets/production.json

{
  "DATABASES": {
    "default": {
      "ENGINE": "django.db.backends.postgresql",
      "HOST": "<AWS RDS end-point>",
      "NAME": "<DB name>",
      "USER": "<DB username>",
      "PASSWORD": "<DB user password",
      "PORT": 5432
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.