Gitlab CI保持在忽略了SQL的文件/docker-entrypoint-initdb.d/*在这个项目。
这是docker-compose.yml:
version: '3.6'
services:
testdb:
image: postgres:11
container_name: lbsn-testdb
restart: always
ports:
- "65432:5432"
volumes:
- ./testdb/init:/docker-entrypoint-initdb.d
Run Code Online (Sandbox Code Playgroud)
这是.gitlab-ci.yml:
stages:
- deploy
deploy:
stage: deploy
image: debian:stable-slim
script:
- bash ./deploy.sh
Run Code Online (Sandbox Code Playgroud)
部署脚本基本上使用 rsync 通过 SSH 将存储库的内容部署到服务器:
rsync -rav --chmod=Du+rwx,Dgo-rwx,u+rw,go-rw -e "ssh -l gitlab-ci" --exclude=".git" --delete ./ "gitlab-ci@$DEPLOY_SERVER:test/"
Run Code Online (Sandbox Code Playgroud)
然后 ssh 进入服务器以停止并重新启动容器:
ssh "gitlab-ci@$DEPLOY_SERVER" "cd test && docker-compose down && docker-compose up --build --detach"
Run Code Online (Sandbox Code Playgroud)
这一切都很顺利,但是当容器启动时,它应该运行/docker-entrypoint-initdb.d/*我们在这里看到的所有文件。
但是相反,在docker …