Mach Django mit CodeStar (Python3.6.8, Django2.2.9)

Erstellen Sie eine Django-App mit CodeStar und CI / CD mit CodePipline.

Entwicklungsumgebung

Lokale Maschine

AWS EC2

Ein Projekt erstellen

    1. Melden Sie sich bei der aws-Konsole an und öffnen Sie CodeStar (möglicherweise benötigten IAM-Benutzer zuvor AWS CloudFormationFullAccess).
  1. Klicken Sie auf Neues Projekt erstellen 01.PNG
    1. Wählen Sie Python (Django), Amazon EC2 02.PNG Vier. Geben Sie den Projektnamen ein (z. B. helloworld) und klicken Sie auf Weiter 03.PNG Fünf. Klicken Sie nach dem Überprüfen der Projektdetails auf Projekt erstellen 04.PNG
  2. Öffnen Sie die Amazon EC2-Verwaltungskonsole in einer neuen Registerkarte 05.PNG
    1. Erstellen Sie ein Schlüsselpaar 14.PNG
  1. Speichern Sie helloworld.pem 15.PNG

  2. Wählen Sie das von Ihnen erstellte Schlüsselpaar aus und klicken Sie auf Projekt erstellen 08.PNG Zehn. Überspringen (AWS Cloud9 war in der Region Oregon)

16.PNG

  1. Das CodeStar-Dashboard wird angezeigt 10.PNG

  2. CodePipline-Quelle → Erstellen → Warten Sie, bis die Bereitstellung abgeschlossen ist 17.PNG

Your requested instance type (t2.micro) is not supported in your requested Availability Zone (us-west-2d). Please retry your request by not specifying an Availability Zone or choosing us-west-2a, us-west-2b, us-west-2c. (Service: AmazonEC2; Status Code: 400; Error Code: Unsupported; Request ID: 7ee63da9-fc85-4e2a-999c-629fe3997dbe)
  1. Öffnen Sie nach Abschluss der Bereitstellung den Anwendungsendpunkt 18.PNG

  2. OK, wenn Sie die Seite sehen können 19.PNG

Bearbeiten eines Projekts (Praxis von CodeCommit)

    1. Durch Klicken auf einen Code im CodeStar-Dashboard wird zu CodeCommit gewechselt 20.PNG
  1. URL vom URL-Klon kopieren 21.PNG

    1. Installieren Sie git für Windows

Vier. Öffnen Sie die Anaconda-Eingabeaufforderung

Fünf. Erstellen Sie eine virtuelle Umgebung für django1 und django2

conda create -n django1 python=3.6
conda create -n django2 python=3.6
  1. IAM CodeCommit-Einstellungen

Die Berechtigungen der IAM-Gruppe sehen wie folgt aus.

AmazonEC2FullAccess
AWSCodeCommitFullAccess
AWSLambdaFullAccess
AmazonS3FullAccess
AmazonDynamoDBFullAccess
AmazonSageMakerFullAccess
AmazonSageMaker-ExecutionPolicy-20191208Txxxxxx
AWSCloudFormationFullAccess

Generieren Sie Anmeldeinformationen aus IAM-Benutzeranmeldeinformationen 46.PNG

    1. Aktivieren Sie die django1-Umgebung und klonen Sie das Projekt. Sie werden nach dem von Ihnen festgelegten Benutzernamen und Passwort gefragt. Der Rest ist git configure.
   (base) $ conda activate django1
(django1) $ git config --global user.email "[email protected]"
(django1) $ git config --global user.name "s-fujimoto"
(django1) $ git clone https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/helloworld
(django1) $ cd helloworld
  1. Schneiden Sie den Entwicklungszweig ab. * Legen Sie sich nicht direkt an den Master. Schneiden Sie den Entwicklungszweig ab, sobald Sie das Projekt erstellen.
(django1) $ git branch develop
(django1) $ git checkout develop
Switched to branch 'develop'
  1. Schneiden Sie den Feature-Zweig ab. * Verpflichten Sie sich nicht direkt zur Entwicklung. Unterbrechen Sie den Feature-Zweig jedes Mal, wenn Sie neue Features hinzufügen oder ändern.
(django1) $ git branch feature
(django1) $ git checkout feature
Switched to branch 'feature'

Zehn. Installieren Sie die erforderlichen Bibliotheken für Ihr Projekt

(django1) $ pip install -r requirements/dev.txt
Collecting Django==1.11.18
  Using cached https://files.pythonhosted.org/packages/e0/eb/6dc122c6d0a82263bd26bebae3cdbafeb99a7281aa1dae57ca1f645a9872/Django-1.11.18-py2.py3-none-any.whl
Collecting pytz
  Using cached https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl
Installing collected packages: pytz, Django
Successfully installed Django-1.11.18 pytz-2019.3

Django 1.11.18 ist installiert

  1. Starten Sie Django lokal
(django1) $ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
December 23, 2019 - 18:15:46
Django version 1.11.18, using settings 'ec2django.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[23/Dec/2019 18:15:54] "GET / HTTP/1.1" 200 6652
[23/Dec/2019 18:15:54] "GET /static/helloworld/css/styles.css HTTP/1.1" 200 2690
[23/Dec/2019 18:15:54] "GET /static/helloworld/js/set-background.js HTTP/1.1" 200 137
[23/Dec/2019 18:15:54] "GET /static/helloworld/css/gradients.css HTTP/1.1" 200 2133
[23/Dec/2019 18:15:54] "GET /static/helloworld/img/tweet.svg HTTP/1.1" 200 1418
[23/Dec/2019 18:15:54] "GET /favicon.ico HTTP/1.1" 404 77
  1. Wenn Sie über Ihren Browser auf http://127.0.0.1:8000/ zugreifen und dieselbe Seite sehen, ist dies in Ordnung. 22.PNG

  2. Siehe Programmänderungen im Git-Status

(django1) $ git status
On branch feature
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        db.sqlite3
        ec2django/__pycache__/
        helloworld/__pycache__/
        helloworld/migrations/__pycache__/

nothing added to commit but untracked files present (use "git add" to track)
  1. Wenn pycache vorhanden ist, schlägt die CodePipline-Bereitstellung fehl. Fügen Sie daher die folgende .gitignore-Datei hinzu (db.sqlite3 ist optional).
 Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

 C extensions
*.so

 Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

 PyInstaller
  Usually these files are written by a python script from a template
  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

 Installer logs
pip-log.txt
pip-delete-this-directory.txt

 Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

 Translations
*.mo
*.pot

 Django stuff:
*.log
local_settings.py

 Flask stuff:
instance/
.webassets-cache

 Scrapy stuff:
.scrapy

 Sphinx documentation
docs/_build/

 PyBuilder
target/

 Jupyter Notebook
.ipynb_checkpoints

 pyenv
.python-version

 celery beat schedule file
celerybeat-schedule

 SageMath parsed files
*.sage.py

 dotenv
.env

 virtualenv
.venv
venv/
ENV/

 Spyder project settings
.spyderproject
.spyproject

 Rope project settings
.ropeproject

 mkdocs documentation
/site

 mypy
.mypy_cache/


.idea/
db.sqlite3
migrations/
    1. Commit to Feature
(django1) $ git add .
(django1) $ git commit -m "add .gitignore"
[feature 6d9a594] add .gitignore
 1 file changed, 106 insertions(+)
 create mode 100644 .gitignore
(django1) $ git push origin feature
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 939 bytes | 939.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/helloworld
 * [new branch]      feature -> feature
  1. Wenn Sie CodeCommit aktivieren, wurde ein Feature-Zweig erstellt 23.PNG

  2. Entwicklungszweig erstellen 24.PNG

  3. Pull-Anfrage erstellen 25.PNG 26.PNG

  4. Vom Feature zum Entwickeln zusammenführen 27.PNG

  5. Löschen Sie die Funktion nach dem Zusammenführen. (Wenn Sie jedoch neue Features hinzufügen oder ändern, schneiden Sie den Feature-Zweig ab. Der Feature-Zweig bleibt lokal, verwenden Sie ihn also unverändert.) 28.PNG

einundzwanzig. Erfolgreiche Zusammenführung 29.PNG

zweiundzwanzig. In ähnlicher Weise von entwickeln zu meistern 30.PNG

dreiundzwanzig. Löschen Sie den Entwicklungszweig nicht 31.PNG

vierundzwanzig. CodePipline startet beim Zusammenführen mit Master 32.PNG

fünfundzwanzig. Stellen Sie sicher, dass die Seite sichtbar ist

Projekt bearbeiten (Update von Django1 auf Django2)

    1. Beenden Sie die django1-Umgebung und aktivieren Sie die django2-Umgebung
(django1) $ conda deactivate
   (base) $ conda activate django2
(django2) $ 
  1. Anforderungen bearbeiten / common.txt Vorher ändern
 dependencies common to all environments
Django==1.11.18

Nach der veränderung

 dependencies common to all environments
Django==2.2.9
  1. Bibliotheksinstallation
(django2) $ pip install -r requirements/dev.txt
Collecting Django==2.2.9
  Using cached https://files.pythonhosted.org/packages/cb/c9/ef1e25bdd092749dae74c95c2707dff892fde36e4053c4a2354b2303be10/Django-2.2.9-py3-none-any.whl
Collecting pytz
  Using cached https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl
Collecting sqlparse
  Using cached https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Installing collected packages: pytz, sqlparse, Django
Successfully installed Django-2.2.9 pytz-2019.3 sqlparse-0.3.0

Django == 2.2.9 ist installiert

    1. Bearbeiten Sie ec2django / settings.py Vorher ändern
MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

Nach der veränderung

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

LANGUAGE_CODE = 'ja'

TIME_ZONE = 'Asia/Tokyo'

USE_I18N = True

USE_L10N = True

USE_TZ = True

Vier. Bearbeiten Sie ec2django / urls.py.

Vorher ändern

from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
   url(r'^admin/', admin.site.urls),
   url(r'^', include('helloworld.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Nach der veränderung

from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('helloworld.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Fünf. Verschieben Sie helloworld / templates / index.html nach helloworld / templates / helloworld / index.html

6.helloworld/urls.py

Vorher ändern

 helloworld/urls.py
from django.conf.urls import url
from django.conf.urls.static import static
from helloworld import views

urlpatterns = [
    url(r'^$', views.HomePageView.as_view()),
]

Nach der veränderung

 helloworld/urls.py
from django.urls import path
from django.conf.urls import url
from django.conf.urls.static import static
from helloworld import views

urlpatterns = [
    path('', views.HomePageView.as_view(), name='index'),
]

7.helloworld/views.py

Vorher ändern

 helloworld/views.py
from django.shortcuts import render
from django.views.generic import TemplateView


 Create your views here.
class HomePageView(TemplateView):
    def get(self, request, **kwargs):
        return render(request, 'index.html', context=None)

Nach der veränderung

 helloworld/views.py
from django.shortcuts import render
from django.views.generic import TemplateView
from django.views import generic

 Create your views here.
class HomePageView(generic.TemplateView):
    template_name = 'helloworld/index.html'
  1. Starten Sie Django lokal, greifen Sie über Ihren Browser auf http://127.0.0.1:8000/ zu. Wenn Sie dieselbe Seite sehen können, ist dies in Ordnung.
(django2) $ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
December 23, 2019 - 19:27:46
Django version 2.2.9, using settings 'ec2django.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[23/Dec/2019 19:27:49] "GET / HTTP/1.1" 200 6652
[23/Dec/2019 19:27:49] "GET /static/helloworld/js/set-background.js HTTP/1.1" 200 137
[23/Dec/2019 19:27:49] "GET /static/helloworld/css/gradients.css HTTP/1.1" 200 2133
[23/Dec/2019 19:27:49] "GET /static/helloworld/css/styles.css HTTP/1.1" 200 2690
[23/Dec/2019 19:27:49] "GET /static/helloworld/img/tweet.svg HTTP/1.1" 200 1418
  1. Verpflichten Sie sich zu Features, verschmelzen Sie zu Entwickeln, verschmelzen Sie von Entwickeln zu Master
(django2) $ git status
On branch feature
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   ec2django/settings.py
        modified:   ec2django/urls.py
        deleted:    helloworld/templates/index.html
        modified:   helloworld/urls.py
        modified:   helloworld/views.py
        modified:   requirements/common.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        helloworld/templates/helloworld/

no changes added to commit (use "git add" and/or "git commit -a")
(django2) $ git add .
(django2) $ git commit -m "django1.11.18 -> django2.2.9"
[feature 2226d88] django1.11.18 -> django2.2.9
 6 files changed, 12 insertions(+), 12 deletions(-)
 rename helloworld/templates/{ => helloworld}/index.html (100%)
(django2) $ git push origin feature
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 8 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (11/11), 1.27 KiB | 648.00 KiB/s, done.
Total 11 (delta 5), reused 0 (delta 0)
To https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/helloworld
 * [new branch]      feature -> feature

33.PNG

Zehn. Überprüfen Sie die Seite, wenn CodePipline abgeschlossen ist 34.PNG

  1. Die Seite ist nicht mehr zugänglich 35.PNG

  2. Öffnen Sie EC2 36.PNG

  3. SSH-Verbindung zu EC2 über TeraTerm (Verwenden Sie für PuTTY PuTTY gen, um das Schlüsselpaar .pem vor dem Verbinden in .ppk zu konvertieren.) 37.PNG

  4. Klicken Sie auf Weiter, um eine Sicherheitswarnung zu erhalten

    1. Geben Sie als Benutzername ec2-Benutzer und Schlüsselpaar an 39.PNG
  5. Verbinden 40.PNG

  6. Starten Sie Django

[ec2-user@ip-172-31-14-214 ~]$ sudo su
[root@ip-172-31-14-214 ec2-user]# source /home/ec2-user/environment/bin/activate
(environment) [root@ip-172-31-14-214 ec2-user]# /usr/local/bin/supervisord -c /home/ec2-user/supervisord.conf
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/local/bin/supervisord -h
(environment) [root@ip-172-31-14-214 ec2-user]# pkill supervisord
(environment) [root@ip-172-31-14-214 ec2-user]# /usr/local/bin/supervisord -c /home/ec2-user/supervisord.conf
  1. Die Seite bleibt unsichtbar. Überprüfen Sie daher das Protokoll
(environment) [root@ip-172-31-14-214 ec2-user]# cat /var/log/django-application-stderr.log
 ・ ・ ・
File "/home/ec2-user/environment/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 63, in check_sqlite_version
    raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
[2019-12-23 19:54:59 +0900] [25438] [INFO] Worker exiting (pid: 25438)
[2019-12-23 10:54:59 +0000] [25435] [INFO] Shutting down: Master
[2019-12-23 10:54:59 +0000] [25435] [INFO] Reason: Worker failed to boot.

Da ich auf Django2 aktualisiert habe, muss ich die Version von SQLite3 aktualisieren.

  1. SQLite3-Update

Lesen Sie den folgenden Artikel Was tun, wenn beim Starten des Entwicklungsservers in Django 2.2 ein SQLite3-Fehler auftritt?

(environment) [root@ip-172-31-14-214 ec2-user]# wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
(environment) [root@ip-172-31-14-214 ec2-user]# tar xvfz sqlite-autoconf-3280000.tar.gz
(environment) [root@ip-172-31-14-214 ec2-user]# cd sqlite-autoconf-3280000
(environment) [root@ip-172-31-14-214 ec2-user]# ./configure --prefix=/usr/local
(environment) [root@ip-172-31-14-214 ec2-user]# make
(environment) [root@ip-172-31-14-214 ec2-user]# sudo make install
(environment) [root@ip-172-31-14-214 ec2-user]# sudo find /usr/ -name sqlite3
(environment) [root@ip-172-31-14-214 ec2-user]# cd ../
(environment) [root@ip-172-31-14-214 ec2-user]# rm sqlite-autoconf-3280000.tar.gz
(environment) [root@ip-172-31-14-214 ec2-user]# rm -rf ./sqlite-autoconf-3280000
(environment) [root@ip-172-31-14-214 ec2-user]# /usr/local/bin/sqlite3 --version
3.28.0 2019-04-16 19:49:53 884b4b7e502b4e991677b53971277adfaf0a04a284f8e483e2553d0f83156b50
(environment) [root@ip-172-31-14-214 ec2-user]# /usr/bin/sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
(environment) [root@ip-172-31-14-214 ec2-user]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
(environment) [root@ip-172-31-14-214 ec2-user]# sudo mv /usr/bin/sqlite3 /usr/bin/sqlite3_old
(environment) [root@ip-172-31-14-214 ec2-user]# sudo ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3
(environment) [root@ip-172-31-14-214 ec2-user]# export LD_LIBRARY_PATH="/usr/local/lib"
(environment) [root@ip-172-31-14-214 ec2-user]# python
Python 3.6.8 (default, Oct 14 2019, 21:22:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.28.0'
>>> exit()
(environment) [root@ip-172-31-14-214 ec2-user]# 

OK, wenn Sie Django starten und die Seite sehen

(environment) [root@ip-172-31-14-214 ec2-user]# pkill supervisord
(environment) [root@ip-172-31-14-214 ec2-user]# /usr/local/bin/supervisord -c /home/ec2-user/supervisord.conf

Stellen Sie ein, dass Django beim Neustart von EC2 gestartet wird

    1. Ändern Sie die Datei Supervisord.conf (bearbeiten Sie sie auch lokal und führen Sie sie später in den Master ein). Vorher ändern
[program:djangoproject]
command = environment/bin/gunicorn -b 0.0.0.0:80 ec2django.wsgi

Nach der veränderung

[program:djangoproject]
command = /home/ec2-user/environment/bin/gunicorn -b 0.0.0.0:80 ec2django.wsgi
  1. Serviceregistrierung
(environment) [root@ip-172-31-14-214 ec2-user]# vi /etc/init.d/helloworld
!/bin/sh
 chkconfig: 2345 99 10
 description: start helloworld
 processname: helloworld

start() {
       echo "start"
       source /home/ec2-user/environment/bin/activate
       export LD_LIBRARY_PATH="/usr/local/lib"
       /usr/local/bin/supervisord -c /home/ec2-user/supervisord.conf
}

stop() {
       echo "stop"
       pkill supervisord
}
case "$1" in
 start)
       start
       ;;
 stop)
       stop
       ;;
 restart)
       stop
       start
       ;;
esac

exit 0
(environment) [root@ip-172-31-14-214 ec2-user]# chkconfig --add helloworld
(environment) [root@ip-172-31-14-214 ec2-user]# chkconfig helloworld on
(environment) [root@ip-172-31-14-214 ec2-user]# chmod u+x /etc/init.d/helloworld
(environment) [root@ip-172-31-14-214 ec2-user]# service helloworld restart
    1. Wenn Sie die Seite auch nach dem Neustart sehen können, ist sie in Ordnung (Django startet auch dann, wenn EC2 gestoppt / gestartet wird).
(environment) [root@ip-172-31-14-214 ec2-user]# sudo reboot

Vier. Ändern Sie die Datei "Supervisord.conf" von Feature und Commit, führen Sie das zu entwickelnde Feature zusammen und führen Sie es von "Entwickeln" zu "Master" zusammen

(django2) $ git status
On branch feature
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   supervisord.conf

no changes added to commit (use "git add" and/or "git commit -a")
(django2) $ git add .
(django2) D:\Users\s-fujimoto\CodeStar\helloworld>git commit -m "modified supervisord.conf"
[feature 38c0e8c] modified supervisord.conf
 1 file changed, 1 insertion(+), 1 deletion(-)
(django2) D:\Users\s-fujimoto\CodeStar\helloworld>git push origin feature
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 325 bytes | 325.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/helloworld
 * [new branch]      feature -> feature

Fünf. OK, wenn CodePipline vollständig ist und Sie die Seite sehen können

(6. Wenn Sie es nicht sehen können, starten Sie EC2 neu oder stellen Sie eine Verbindung mit SSH her, um das Protokoll zu überprüfen und den Dienst neu zu starten.)

(environment) [root@ip-172-31-14-214 ec2-user]# cat /var/log/django-application-stderr.log
(environment) [root@ip-172-31-14-214 ec2-user]# cat /var/log/django-application-stdout.log
(environment) [root@ip-172-31-14-214 ec2-user]# service helloworld restart

Erzwungene Bereitstellung

Selbst wenn Sie es in dem Zustand erneut versuchen, in dem die Bereitstellung einmal fehlgeschlagen ist, schlägt sie erneut fehl. Wenn Sie also die Bereitstellung erzwingen und dann mit dem Master zusammenführen, ist dies erfolgreich.

Eine Geschichte, nach der ich süchtig war, weil ich appspec.yml und buildspec.yml keine Dateien hinzugefügt habe

    1. Wählen Sie das Ziel aus der CodeDeploy-Anwendung aus 43.PNG
  1. Geben Sie den Speicherort der fehlgeschlagenen Revision an 44.PNG
    1. Aktivieren Sie die Option Bereitstellung nicht fehlschlagen, wählen Sie Inhalt überschreiben aus und erstellen Sie die Bereitstellung für die Bereitstellung 45.PNG

Verwenden Sie ein benutzerdefiniertes Benutzermodell (weggelassen).

db.sqlite3 ist .gitignore, senden Sie es also mit Tera Term AWS EC2-Verbindungsmethode (Linux-System) und Dateiübertragungsmethode

DB muss aktualisiert werden

python manage.py makemigrations helloworld
python manage.py migrate

Projekt löschen

    1. Aus der CodeStar-Projektliste entfernt 12.PNG
  1. Geben Sie den Projektnamen ein und löschen Sie 13.PNG

Zusammenfassung

Ich bin der Meinung, dass die Entwicklung der Django-App viel einfacher geworden ist. CICD Viel Glück.

Recommended Posts

Mach Django mit CodeStar (Python3.6.8, Django2.2.9)
Mach Django mit CodeStar (Python3.8, Django2.1.15)
Django 1.11 wurde mit Python3.6 gestartet
Mach Houdini mit Python3! !! !!
Python3 + Django ~ Mac ~ mit Apache
Erste Schritte mit Python Django (1)
Erste Schritte mit Python Django (4)
Erste Schritte mit Python Django (3)
Führen Sie eine AES-Verschlüsselung mit DJango durch
Einführung in Python Django (6)
Erste Schritte mit Python Django (5)
Schwanzrekursion mit Python2 durchführen
Was tun mit PYTHON Release?
Führen Sie python3 Django1.9 mit mod_wsgi aus (deploy)
Lassen Sie uns mit Python Image Scraping durchführen
Python | Was Sie mit Python machen können
So führen Sie eine arithmetische Verarbeitung mit der Django-Vorlage durch
FizzBuzz in Python3
Scraping mit Python
Statistik mit Python
Python Django Tutorial (5)
Python Django Tutorial (2)
Scraping mit Python
Python mit Go
Internationalisierung mit Django
Twilio mit Python
Lassen Sie Heroku die Hintergrundverarbeitung mit Python durchführen
In Python integrieren
Spielen Sie mit 2016-Python
AES256 mit Python
Getestet mit Python
Python Django Tutorial (8)
Wie man einen Taschentest mit Python macht
Python beginnt mit ()
CentOS 6.4, Python 2.7.3, Apache, mod_wsgi, Django
Python Django Tutorial (6)
mit Syntax (Python)
CRUD mit Django
Bingo mit Python
Zundokokiyoshi mit Python
Lassen Sie uns MySQL-Daten mit Python bearbeiten
Python Django Tutorial (7)
Python Django Tutorial (1)
Python Django Tutorial Tutorial
Python Django Tutorial (3)
Excel mit Python
Mikrocomputer mit Python
Python Django Tutorial (4)
Mit Python besetzen
Ich möchte es mit Python Lambda Django machen, aber ich werde aufhören
[AWS] Erstellen Sie mit CodeStar eine Python Lambda-Umgebung und führen Sie Hello World aus
Ich kann mit Python3.5 (Windows) + django1.7.1 kein Projekt erstellen.
So führen Sie eine Mehrkern-Parallelverarbeitung mit Python durch
[Python] Erstellen Sie mit Docker eine Django-Entwicklungsumgebung
Erstellen Sie mit Docker eine Umgebung aus Nginx + uWSGI + Python (Django)
Django mit Python Tools 2.2 für Visual Studio (PTVS 2.2)
Einfache Aufgabenliste, erstellt mit Python + Django
Python-Anfänger süchtig nach Django
Erstellen Sie mit IntelliJ schnell eine Python Django-Umgebung
Web Scraping mit Python (Wettervorhersage)
Web Scraping mit Python (Aktienkurs)