google-cloud-platform - 无法在谷歌云构建上正确初始化 mysql db(使用 docker-compose)
问题描述
我目前正在使用 Google Cloud Build(并使用 测试cloud-build-local
)为我的应用程序(django)设置构建/测试管道。
为了正确运行测试,我需要启动一个 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
直接运行正常
我怀疑卷的安装方式不正确,但找不到原因/方式。
如果有人对此有任何意见,那将非常有用:)
提前致谢。
解决方案
看起来这是一个问题cloud-build-local
,在 GCP 上正常工作
推荐阅读
- postman - “类型”对象不是可迭代的 drf
- javascript - Reactjs if 条件
- android-recyclerview - 单击 recyclerview 行时,微调器选择的值返回到旧值
- sql - 如何在 SQL 中将调整因子应用于股票价格?
- authentication - 为什么 laravel 中间件实现了 web.php 中的所有路由
- c++ - OpenMP - 预计数据竞争情况但实际上并未发生
- visual-studio-code - VS Code 中数字行左侧的断点点附近/上方的这条白线是什么?
- c# - 对 datagridview 中列的不同值求和
- regex - 如何提取谷歌表格中所有数字的箭头后的值?
- java - 如何不让用户输入空白?