Как исправить ошибку сборки, конвертирующую YAML в JSON? - PullRequest
1 голос
/ 30 января 2020

Следующее происходит, когда я git push heroku master

Enumerating objects: 96, done.
Counting objects: 100% (96/96), done.
Delta compression using up to 4 threads
Compressing objects: 100% (94/94), done.
Writing objects: 100% (96/96), 37.53 KiB | 1.50 MiB/s, done.
Total 96 (delta 14), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: === Fetching app code
remote: 
remote: =!= Build failed due to an error:
remote: 
remote: =!= validate step: error converting YAML to JSON: yaml: line 11: mapping values are not allowed in this context
remote: 
remote: If this persists, please contact us at https://help.heroku.com/.
remote: Verifying deploy...
remote: 
remote: !   Push rejected to mighty-stream-60397.
remote: 
To https://git.heroku.com/mighty-stream-60397.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mighty-stream-60397.git'

У меня есть два файла yml, один из них heroku.yml, а другой docker -compose.yml

setup:
  addons:
  - plan: heroku-postgresql

build:
  docker:
    web: Dockerfile

release:
  image:web
  command:
    - python manage.py collectstatic --noinput

run:
  web: python manage.py runserver
version: '3.7'

services:
  redis:
    image: redis:2.8
    restart: always
    ports:
      - 6379:6379
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - 8000:8000
    depends_on:
      - db

  db:
    image: postgres:11
    volumes:
      - postgres_data:/var/lib/postgresql/data/


volumes:
  postgres_data:

Я не уверен, где проблема? docker -compose может собрать файл, так что я предполагаю, что проблема в heroku.yml, но я попытался удалить строку 11, закомментировать ее, и она все еще не работает. Я действительно новичок в этом деле и, честно говоря, понятия не имею, что здесь происходит. Помогите? спасибо, mch

edit: это то, что в моем журнале сборки (точно такая же ошибка)

=== Fetching app code
=!= Build failed due to an error:
=!= validate step: error converting YAML to JSON: yaml: line 11: mapping values are not allowed in this context
If this persists, please contact us at https://help.heroku.com/.

1 Ответ

0 голосов
/ 31 января 2020

Хорошо, так что я до сих пор не совсем понимаю, что случилось, но удаление python manage.py collectstatic --noinput сработало для меня. Мой docker -compose файл вообще не имел проблем - хотя следует отметить, что использование команды runserver также не является хорошей идеей. Я закончил тем, что переключился на Дафну, и мой супер простой heroku.yml выглядит следующим образом

setup:
  addons:
  - plan: heroku-postgresql

build:
  docker:
    web: Dockerfile

release:
  image: web

run:
  web: daphne test_project.asgi:application --port $PORT --bind 0.0.0.0 -v2

, который работает! Надеюсь, что это может помочь любому

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...