我想在测试阶段使用sql文件初始化我的service。
test:
services:
- postgres:latest
variables:
POSTGRES_DB: test
stage: test
image: gliderlabs/herokuish:latest
script:
- setup_test_db
- cp -R . /tmp/app
- /bin/herokuish buildpack test
only:
- branches
except:
variables:
- $TEST_DISABLED这是auto devops中的测试作业。
我想使用postgres镜像docker-entrypoint。
下面是我在pc上的docker-compose中使用它的方法:
volumes:
- './src/sql:/docker-entrypoint-initdb.d'这样,当postres映像启动时,我就有了可以使用的模式。
我怎样才能在gitlab-ci.yml中做到这一点?
发布于 2020-11-12 10:02:10
目前,Gitlab CI中不支持volumes。
在测试期间,您可以使用docker-compose,它提供了一项针对postgres的服务来启动您的项目,您可以照常挂载它的卷
发布于 2022-01-07 07:35:31
你可以将下面的脚本添加到你的gitlab ci中以使其工作。
before_script:
- apt update && apt install -y postgresql
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f ./src/sqlhttps://stackoverflow.com/questions/53449106
复制相似问题