簡體   English   中英

在 Github 操作/工作流中使用 ddev

[英]using ddev in Github actions/workflows

我用 ddev 設置了驗收測試。 它們在ddev composer cookieman:test上本地運行。 我想對 Github 操作使用相同的設置。

有人在 Github 操作/工作流程中對 ddev 有任何運氣嗎? 我一直到這里 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:

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

我試過了

  • 使用 Ubuntu 16.04

  • 全面升級 Ubuntu 16.04/18.04 上的所有軟件包

  • 像這樣配置ddev:

    • run: ddev config global --router-bind-all-interfaces=true
    • run: ddev config global --omit-containers=dba,ddev-ssh-agent
  • 更改為非特權路由器端口(在 config.yaml 中設置 router_http_port、router_https_port)

如果我強制它繼續ddev start || exit 0 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產生默認的 nginx 起始頁(雖然我希望“503:沒有可用的 ddev 后端站點”)

curl 127.0.0.1/healthcheck產生 404

到目前為止,我的結論是:ddev-router 是可訪問的,但它的 nginx 沒有適當的配置(/etc/nginx/conf.d/default.conf 的上游沒有服務器)。 因此 ddev 只運行 config.yaml 的預啟動鈎子形式。 未達到啟動后。

您可以在此處查看上次運行的output https://github.com/dmind-gmbh/extension-cookieman/actions?query=branch%3Afeat%2Facceptance-tests

編輯/修改:這是(惡意)生成的/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 提到了 ddev-router 和底層 docker 守護進程通過 sockets 之間的通信錯誤。

編輯:我將我的發現放入一個 Github 動作中,該動作也可以包含在其他項目中: https://github.com/marketplace/actions/setup-ddev

我得出的結論是問題出在 docker-gen 上。

在模板的第一行( 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

建議刪除“-only-exposed”對我不起作用。 我稍微改變了模板,而不是依賴容器,就是這樣。

:)

這仍然有點臟,只是一個概念證明:

  • 這是更改后的模板https://github.com/jonaseberle/github-action-setup-ddev/blob/master/.ddev/patches/ddev-router/nginx.tmpl (比較我刪除的上游 {} 部分檢查容器是否與路由器在同一個網絡上)

  • 在我做的工作流程中

    • ddev start || exit 0 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"
    • ... ddev 現在正常運行

沒有決定如何從這里繼續前進。 也許@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...

編輯/修改:

較短且經過測試的版本是:

  • ddev start || docker cp.ddev/patches/ddev-router/nginx.tmpl ddev-router:/app/nginx.tmpl
  • ddev start - 這會觸發容器重啟,從而觸發 docker-gen 運行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM