LoginSignup
0
0

More than 3 years have passed since last update.

Django3チュートリアル準備

Posted at

Django3の環境構築をdockerで行う

環境構築

Django3.0の開発環境をDocker,Docker-compose,Poetryで作ってみた
上記の記事がシンプルで分かりやすかったので、参考にしました。
私の環境では下記のディレクトリー 構造となりました。
Makefileは私が作成したものです。
記事の最後に載せてあります。

.
├── Dockerfile
├── docker-compose.yml
├── Makefile
└── src
    ├── manage.py
    ├── project
    ├── pyproject.toml
    └── poetry.lock

git管理する

//git config でユーザー名と設定
git config --global user.email "xxx.yyy@example"
git config --global user.name "password"

//git hubでリポジトリの作成後リモートリポジトリの追加をします。
git remote add origin [remote repository PATH]

//git pullを実行し設定終了
git pull

.gitignore 作成

Djangoについて全くと言っていいほど理解しておらず【gitignore】に追加すべきファイルがわからなったので、gitignore.ioで作成
https://www.toptal.com/developers/gitignore

Makefile作成

dockerコマンドは長いので打つのが面倒なので、Makefileに記述しています。

up:
    docker-compose up -d

build:
    docker-compose build --no-cache --force-rm

stop:
    docker-compose stop
down:
    docker-compose down

restart:
    @make down
    @make up

destroy:
    docker-compose down --rmi all --volumes

django:
    docker exec -it django3_django_1 bash

参考にさせていただいた記事

Django3.0の開発環境をDocker,Docker-compose,Poetryで作ってみた
#django 用の .gitignore を一瞬で自動生成する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0