Git Product home page Git Product logo

banatech_django's Introduction

banaTECH

Djangoを用いたWebサイトbanaTECHのソースコード Webアプリやプログラミングやガジェットに関するブログを掲載 現在はLaraveに移行->(https://github.com/bana118/banatech_laravel)

ローカルでの実行

 

> python banatech/manage.py runserver

管理ユーザー作成

> python banatech/manage.py createsuperuser

データベース作成

> python banatech/manage.py makemaigration
> python banatech/manage.py migrate

新規アプリケーション作成

> python banatech/manage.py startapp ${appname}

デプロイ(docker)

  1. チェックアウト
> git checkout deploy-https
  1. SEACRET_KEY設定 banatech/banatech/local_settings.pyにSEACRET_KEYを設定
SECRET_KEY = 自分で設定

ランダム生成用プログラム

from django.core.management.utils import get_random_secret_key

secret_key = get_random_secret_key()
text = 'SECRET_KEY = \'{0}\''.format(secret_key)
print(text)
  1. nginx-app.confをletsencrypt認証用にする
> mv nginx-app.conf nginx-app.conf.prod
> mv nginx-app.conf.tmp nginx-app.conf
  1. デプロイ
> sudo docker build -t django-https .
> sudo docker run -d -p 80:80 -p 443:443 -v /home/docker/code:/home/docker/code -v /etc/letsencrypt:/etc/letsencrypt django-https
  1. letsencrypt認証
> apt-get install certbot
> sudo certbot certonly --webroot -w /home/docker/code/banatech/static -d banatech.dip.jp
  1. nginx-app.confを本番用にする
> mv nginx-app.conf nginx-app.conf.temp
> mv nginx-app.conf.prod nginx-app.conf
  1. 再度デプロイ
> sudo docker stop ${container_id}
> sudo docker rm ${exist_container_id}
> sudo docker build -t django-https .
> sudo docker run -d -p 80:80 -p 443:443 -v /home/docker/code:/> home/docker/code -v /etc/letsencrypt:/etc/letsencrypt django-https
  1. letsencrypt更新確認
> sudo certbot renew --force-renew --dry-run --webroot-path /home/docker/code/banatech/static
  1. letsencrypt自動更新
> crontab -e

crontabに以下追記

0 4 1 * * sudo certbot renew && sudo docker restart ${container_id}

更新

> sudo git pull
> cd ..
> sudo rm -rf docker/code/*
> sudo cp -pR banatech_django/* docker/code
> sudo docker restart ${container_id}

docker内確認

sudo docker exec -i -t ${container_id} bash

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.