Aws Beanstalk eb deploy relative path makemigrations ERROR Failed to deploy application
Я продолжаю получать 2022-07-08 03:11:06 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
и ERROR: ServiceError - Failed to deploy application.
при попытке запустить eb deploy
при развертывании приложения Django на Elastic Beanstalk на aws. На Command 01_makemigrations
, похоже, происходит сбой. Но вот что заставляет меня сходить с ума; models.py
прекрасно работает в http://127.0.0.1:8000/
(локально) с этой одной строкой: image = models.ImageField(upload_to=os.path.join(BASE_DIR, 'static'), null=True, blank=True)
.
Я заметил, что именно эта строка кода в модели вызывает проблему при развертывании на производстве. Я закомментировал ее, и она развернулась нормально, но мне явно нужен этот метод... Может ли это быть связано с проблемой пути Linux vs. Windows?... Я разрабатываю локально в Windows 10. 👽
django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: the_slim_fatty.wsgi:application
container_commands:
01_makemigrations:
command: "source /var/app/venv/*/bin/activate && python3 manage.py makemigrations --noinput"
leader_only: true
02_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate --noinput"
leader_only: true
03_superuser:
command: "source /var/app/venv/*/bin/activate && python3 manage.py createsu"
leader_only: true
eb-engine.log
2022/07/08 03:11:06.780830 [INFO] Error occurred during build: Command 01_makemigrations failed
2022/07/08 03:11:06.780855 [ERROR] An error occurred during execution of command [app-deploy] - [PostBuildEbExtension]. Stop running the command. Error: container commands build failed. Please refer to /var/log/cfn-init.log for more details.
cfn-init.log
2022-07-08 03:11:06,752 [ERROR] Command 01_makemigrations (source /var/app/venv/*/bin/activate && python3 manage.py makemigrations --noinput) failed
2022-07-08 03:11:06,752 [ERROR] Error encountered during build of postbuild_0_the_slim_fatty: Command 01_makemigrations failed
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 01_makemigrations failed
2022-07-08 03:11:06,755 [ERROR] -----------------------BUILD FAILED!------------------------
2022-07-08 03:11:06,755 [ERROR] Unhandled exception during build: Command 01_makemigrations failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 176, in <module>
worklog.build(metadata, configSets)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 137, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 564, in build
self.run_config(config, worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 01_makemigrations failed
models.py
import os
from django.db import models
from django.contrib.auth.models import User
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
STATUS = (
(0,"Draft"),
(1,"Publish")
)
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts')
updated_on = models.DateTimeField(auto_now= True)
content = models.TextField()
created_on = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(choices=STATUS, default=0)
# image = models.ImageField(upload_to=os.path.join(BASE_DIR, 'static'), null=True, blank=True) #creates folder called amiibo under the main media folder and uploads there
image = models.ImageField(upload_to='static', null=True, blank=True) #creates folder called amiibo under the main media folder and uploads there
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.title