gpt4 book ai didi

git - 如何修复将YAML转换为JSON的构建错误?

转载 作者:行者123 更新时间:2023-12-02 19:52:04 25 4
gpt4 key购买 nike

当我做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行,将其注释掉,但仍然失败。我真的是新手,老实说,我不知道这是怎么回事。救命?非常感谢

编辑:这是我的构建日志中的内容(完全相同的错误)
=== 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/.

最佳答案

好的,所以我仍然不太了解发生了什么,但是删除python manage.py collectstatic --noinput对我有用。我的docker-compose文件完全没有问题-尽管应该注意,使用runserver命令也不是一个好主意。我最终切换到daphne,我的 super 简单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

哪个有效!希望这可以帮助任何人

关于git - 如何修复将YAML转换为JSON的构建错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59977409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com