From 9a969850738c8df222b3731d41159f5b3f6e8316 Mon Sep 17 00:00:00 2001 From: noopy Date: Sun, 12 Apr 2020 22:14:18 +0900 Subject: [PATCH 1/2] update postgres initialization for compose/django.md --- compose/django.md | 71 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/compose/django.md b/compose/django.md index 32f78e79edea..2489cb62deeb 100644 --- a/compose/django.md +++ b/compose/django.md @@ -60,23 +60,31 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi expose. See the [`docker-compose.yml` reference](/compose/compose-file/index.md) for more information on how this file works. -9. Add the following configuration to the file. +9. Add the following configuration to the file. ```none - version: '3' - - services: - db: - image: postgres - web: - build: . - command: python manage.py runserver 0.0.0.0:8000 - volumes: - - .:/code - ports: - - "8000:8000" - depends_on: - - db + # docker-compose.yml + + version: '3' + + services: + db: + image: postgres + ports: #add line. + - '5432' + environment: # add line. + - POSTGRES_DB=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - db ``` This file defines two services: The `db` service and the `web` service. @@ -138,21 +146,24 @@ In this section, you set up the database connection for Django. 1. In your project directory, edit the `composeexample/settings.py` file. -2. Replace the `DATABASES = ...` with the following: - - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'postgres', - 'USER': 'postgres', - 'HOST': 'db', - 'PORT': 5432, - } - } - - These settings are determined by the - [postgres](https://hub.docker.com/_/postgres) Docker image - specified in `docker-compose.yml`. +2. Replace the `DATABASES = ...` with the following: + + # setting.py + + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'postgres', + 'USER': 'postgres', + 'PASSWORD': 'postgres', #add line. + 'HOST': 'db', + 'PORT': 5432, + } + } + + These settings are determined by the + [postgres](https://hub.docker.com/_/postgres) Docker image + specified in `docker-compose.yml`. 3. Save and close the file. From 920975c2c920344e01c488960575641b6e5f7697 Mon Sep 17 00:00:00 2001 From: noopy Date: Thu, 16 Apr 2020 02:12:50 +0900 Subject: [PATCH 2/2] omitted code blocks with postgres ports & comments --- compose/django.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compose/django.md b/compose/django.md index 2489cb62deeb..07f55215de13 100644 --- a/compose/django.md +++ b/compose/django.md @@ -63,16 +63,12 @@ and a `docker-compose.yml` file. (You can use either a `.yml` or `.yaml` extensi 9. Add the following configuration to the file. ```none - # docker-compose.yml - version: '3' services: db: image: postgres - ports: #add line. - - '5432' - environment: # add line. + environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres @@ -155,7 +151,7 @@ In this section, you set up the database connection for Django. 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', - 'PASSWORD': 'postgres', #add line. + 'PASSWORD': 'postgres', 'HOST': 'db', 'PORT': 5432, }