[英]using ddev in Github actions/workflows
I have acceptance tests set up with ddev.我用 ddev 设置了验收测试。 They get run locally on ddev composer cookieman:test
.它们在ddev composer cookieman:test
上本地运行。 I would like to use the same setup with Github actions.我想对 Github 操作使用相同的设置。
Did anybody have any luck with ddev in Github actions/workflow?有人在 Github 操作/工作流程中对 ddev 有任何运气吗? I am getting until here where ddev's healthcheck fails:我一直到这里 ddev 的健康检查失败:
... Creating ddev-router ... done Failed to start extension-cookieman-master: ddev-router failed to become ready: logOutput=2019/11/15 02:24:19 [emerg] 1630#1630: no servers are inside upstream in /etc/nginx/conf.d/default.conf:89 nginx: [emerg] no servers are inside upstream in /etc/nginx/conf.d/default.conf:89 nginx: configuration file /etc/nginx/nginx.conf test failed % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (22) The requested URL returned error: 404 Not Found ddev-router healthcheck endpoint not responding , err=container /ddev-router unhealthy: 2019/11/15 02:24:19 [emerg] 1630#1630: no servers are inside upstream in /etc/nginx/conf.d/default.conf:89 nginx: [emerg] no servers are inside upstream in /etc/nginx/conf.d/default.conf:89 nginx: configuration file /etc/nginx/nginx.conf test failed % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (22) The requested URL returned error: 404 Not Found ddev-router healthcheck endpoint not responding ##[error]Process completed with exit code 1.
.github/workflows/tests.yml: .github/workflows/tests.yml:
name: Tests on: [push, pull_request] jobs: tests-via-ddev: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - run: export DEBIAN_FRONTEND=noninteractive # update docker - run: sudo -E apt-get purge -y docker docker-engine docker.io containerd runc nginx - run: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - run: sudo -E add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - run: sudo -E apt-get update - run: sudo -E apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce # install linuxbrew - run: sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" - run: echo "::add-path::/home/linuxbrew/.linuxbrew/bin" # install ddev + docker-compose - run: brew tap drud/ddev && brew install ddev docker-compose # Start ddev - run: ddev start || exit 0 # Debug - run: ls -als .ddev/ - run: curl 127.0.0.1 || exit 0 - run: curl 127.0.0.1/healthcheck || exit 0 - run: docker ps || exit 0 # we want Clover coverage - run: ddev exec enable_xdebug # Run tests - run: ddev composer cookieman:test
I tried我试过了
using Ubuntu 16.04使用 Ubuntu 16.04
fully upgrading all packages on Ubuntu 16.04/18.04全面升级 Ubuntu 16.04/18.04 上的所有软件包
configuring ddev like that:像这样配置ddev:
run: ddev config global --router-bind-all-interfaces=true
run: ddev config global --omit-containers=dba,ddev-ssh-agent
changing to unprivileged router ports (settings router_http_port, router_https_port in config.yaml)更改为非特权路由器端口(在 config.yaml 中设置 router_http_port、router_https_port)
If I force it to continue with ddev start || exit 0
如果我强制它继续ddev start || exit 0
ddev start || exit 0
I can see containers up and running: ddev start || exit 0
我可以看到容器启动并运行:
- run: docker ps || exit 0
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c36601a06fd6 drud/ddev-router:v1.11.0 "/app/docker-entrypo…" 27 seconds ago Up 24 seconds (unhealthy) 0.0.0.0:4430->4430/tcp, 0.0.0.0:4444->4444/tcp, 0.0.0.0:8025->8025/tcp, 80/tcp, 0.0.0.0:8080->8080/tcp ddev-router 18152602a054 drud/ddev-webserver:v1.11.0-built "/start.sh" 30 seconds ago Up 28 seconds (healthy) 8025/tcp, 127.0.0.1:32770->80/tcp, 127.0.0.1:32769->443/tcp ddev-extension-cookieman-master-web 33aca55715f2 selenium/standalone-chrome:3.12 "/opt/bin/entry_poin…" 32 seconds ago Up 30 seconds 4444/tcp ddev-extension-cookieman-master-chrome 6c852ae62974 drud/ddev-dbserver:v1.11.0-10.2-built "/docker-entrypoint.…" 32 seconds ago Up 30 seconds (healthy) 127.0.0.1:32768->3306/tcp ddev-extension-cookieman-master-db
curl 127.0.0.1
yields the default nginx start page (while I would expect '503: No ddev back-end site available') curl 127.0.0.1
产生默认的 nginx 起始页(虽然我希望“503:没有可用的 ddev 后端站点”)
curl 127.0.0.1/healthcheck
yields a 404 curl 127.0.0.1/healthcheck
产生 404
So far my conclusion is: ddev-router is reachable but its nginx does not have the appropriate configuration (no servers are inside upstream in /etc/nginx/conf.d/default.conf).到目前为止,我的结论是:ddev-router 是可访问的,但它的 nginx 没有适当的配置(/etc/nginx/conf.d/default.conf 的上游没有服务器)。 Thus ddev only runs the pre-start hook form config.yaml.因此 ddev 只运行 config.yaml 的预启动钩子形式。 post-start is not reached.未达到启动后。
You can see the output of the last runs here https://github.com/dmind-gmbh/extension-cookieman/actions?query=branch%3Afeat%2Facceptance-tests您可以在此处查看上次运行的output https://github.com/dmind-gmbh/extension-cookieman/actions?query=branch%3Afeat%2Facceptance-tests
EDIT/AMEND: This is the (mal-)generated /etc/nginx/conf.d/default.conf
from ddev-router
:编辑/修改:这是(恶意)生成的/etc/nginx/conf.d/default.conf
来自ddev-router
:
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
# ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
default off;
https on;
}
rfay mentioned a miscommunication between the ddev-router and the underlying docker daemon via sockets. rfay 提到了 ddev-router 和底层 docker 守护进程通过 sockets 之间的通信错误。
I came to the conclusion that the problem is with docker-gen.我得出的结论是问题出在 docker-gen 上。
In the first line of the template ( https://github.com/drud/ddev/blob/master/containers/ddev-router/nginx.tmpl or also jwilder's https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl ) the.Docker.CurrentContainerID is empty which seemed to happen to some people in some contexts https://github.com/jwilder/docker-gen/issues/196#issuecomment-225412753 .在模板的第一行( https://github.com/drud/ddev/blob/master/containers/ddev-router/nginx.tmpl或者 jwilder 的https://github.com/jwilder/nginx-proxy/ blob/master/nginx.tmpl ) the.Docker.CurrentContainerID 是空的,在某些情况下似乎发生在某些人身上 https://github.com/jwilder/docker-gen/issues/196#issuecomment-225412753 。
The suggested removal of '-only-exposed' did not work for me.建议删除“-only-exposed”对我不起作用。 I changed the template a bit instead to not rely on the container and that was it.我稍微改变了模板,而不是依赖容器,就是这样。
:) :)
This is still a bit dirty and only a Proof-of-concpet:这仍然有点脏,只是一个概念证明:
this is the changed template https://github.com/jonaseberle/github-action-setup-ddev/blob/master/.ddev/patches/ddev-router/nginx.tmpl (compare the upstream {} section where I removed the check if containers are on the same network with the router)这是更改后的模板https://github.com/jonaseberle/github-action-setup-ddev/blob/master/.ddev/patches/ddev-router/nginx.tmpl (比较我删除的上游 {} 部分检查容器是否与路由器在同一个网络上)
In the workflow I do在我做的工作流程中
ddev start || exit 0
ddev start || exit 0
# this will fail and also not execute any post-start hooks ddev start || exit 0
# 这将失败,也不会执行任何启动后挂钩docker cp nginx-debug.tmpl ddev-router:/app/nginx-debug.tmpl
docker exec ddev-router sh -c "docker-gen -only-exposed -notify 'sleep 1 && nginx -s reload' /app/nginx-debug.tmpl /etc/nginx/conf.d/default.conf"
Not decided how to move on from here.没有决定如何从这里继续前进。 Maybe @rfay would have an idea how to change the nginx-template.也许@rfay 会知道如何更改 nginx 模板。 Or I will use a custom Dockerfile for the ddev-router with a docker-compose.ddev-router.yaml to change the file just for the Github actions run... Or I will use a custom Dockerfile for the ddev-router with a docker-compose.ddev-router.yaml to change the file just for the Github actions run...
EDIT/AMEND:编辑/修改:
The shorter and tested version of this is:较短且经过测试的版本是:
ddev start || docker cp.ddev/patches/ddev-router/nginx.tmpl ddev-router:/app/nginx.tmpl
ddev start
- this triggers a container restart and thus a docker-gen run ddev start
- 这会触发容器重启,从而触发 docker-gen 运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.