LoginSignup
1
0

[Python] Django+Gunicorn+NginxのDockerCompose環境

Last updated at Posted at 2024-02-29

はじめに

Djangoのローカル開発環境の簡易テンプレートを作成しました。
目的は、Pythonフレームワークに触ってみたいのと、Djangoの開発環境を知りたかったためです。

あくまで開発環境なので、Djangoのビルトインサーバーであるrunserverで事足りるかもしれませんが、実環境に寄せる目的でnginxとgunicornも用意することにしました。

以下は、Djangoのrunserver機能に関する記述です。

このサーバーを実稼働環境で使用しないでください。セキュリティ監査やパフォーマンス テストは受けていません。(そして、それが今後も続くでしょう。私たちは Web サーバーではなく Web フレームワークを作成する仕事をしているので、運用環境を処理できるようにこのサーバーを改善することは Django の範囲外です。)

前提環境

Docker Compose 構成

Docker Composeの構成を記述します。

サービス一覧

  • app
  • web
  • db_pgsql

app

Djangoとgunicornを使用したアプリケーションサーバー。
gunicornが8000ポートを使用し、nginxからの中継に応答します。

web

nginxサーバー。
HTTPリクエストをappコンテナへとフォワード(中継)します。

db_pgsql

PostgreSQLサーバー。

Github

1
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
1
0