【发布时间】:2019-10-21 15:33:22
【问题描述】:
我目前正在使用 Google Cloud Build 为我的应用 (django) 设置构建/测试管道(并使用 cloud-build-local 进行测试)。
为了正确运行测试,我需要启动一个 mysql 依赖项(我为此使用 docker-compose)。问题是在云构建步骤中运行 docker-compose 时,数据库初始化脚本没有正确运行,我得到一个
/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/0-init.sql
ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.
(在 google-cloud-build 之外运行 docker-compose 正常工作)
这是我的 docker-compose 文件:
version: '3.3'
services:
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: 'dev'
MYSQL_USER: 'dev'
MYSQL_PASSWORD: 'dev'
MYSQL_ROOT_PASSWORD: 'root'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- reports-db:/var/lib/mysql-reports
- ./dev/databases/init.sql:/docker-entrypoint-initdb.d/0-init.sql
- ... (other init scripts)
volumes:
reports-db:
还有cloudbuild.yaml:
steps:
...
- id: 'tests-dependencies'
name: 'docker/compose:1.24.1'
args: ['up', '-d']
...
文件是这样组织的:
parent_dir/
dev/
databases/
init.sql
cloudbuild.yaml
docker-compose.yml
...
(所有命令都从parent_dir/运行)
当我跑步时
cloud-build-local --config=cloudbuild.yaml --dryrun=false .
我得到一个
...
Step #2 - "tests-dependencies": mysql_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/0-init.sql
Step #2 - "tests-dependencies": mysql_1 | ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.
...
知道直接运行docker-compose up可以正常工作
我怀疑卷的安装方式不正确,但找不到原因/方式。
如果有人对此有任何意见,那将非常有用:)
提前致谢。
【问题讨论】:
-
你的卷定义为空正常吗?
-
是的,它可以为空,在这种情况下,您使用默认驱动程序。基本上,随着数据库正确启动(并且在云构建运行命令结束时可以访问),此特定卷已正确安装和访问。
标签: google-cloud-platform docker-compose google-cloud-build