为什么赛普拉斯无法检测到 运行 网络服务器?
Why Cypress can't detect running webserver?
我的容器都是 运行ning,我正在尝试 运行 Cypress 测试反对它:
docker-compose.yml:
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile
volumes:
- './services/users:/usr/src/app'
expose:
- 5000
environment:
- FLASK_APP=project/__init__.py
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgresql://postgres:postgres@users-db:5432/users_dev
- DATABASE_TEST_URL=postgresql://postgres:postgres@users-db:5432/users_test
- SECRET_KEY='hakuna matata'
depends_on:
- users-db
client:
build:
context: ./services/client
dockerfile: Dockerfile
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3007:3000
environment:
- CHOKIDAR_USEPOLLING=true
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
depends_on:
- users
users-db:
build:
context: ./services/users/project/db
dockerfile: Dockerfile
expose:
- 5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
nginx:
build:
context: ./services/nginx
dockerfile: Dockerfile
restart: always
ports:
- 80:80
depends_on:
- users
- client
cypress.json:
{
"baseUrl": "http://nginx:80",
"video": false
}
docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97f91a4b3a81 tdd_nginx "/docker-entrypoint.…" 56 minutes ago Up 56 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp tdd_nginx_1
089cd20326c1 tdd_client "npm start" 56 minutes ago Up 56 minutes 0.0.0.0:3007->3000/tcp, :::3007->3000/tcp tdd_client_1
85dc333cc487 tdd_users "/usr/src/app/entryp…" 56 minutes ago Up 56 minutes 5000/tcp tdd_users_1
696298d0ab2c tdd_users-db "docker-entrypoint.s…" 56 minutes ago Up 56 minutes 5432/tcp tdd_users-db_1
错误输出:
Cypress could not verify that the server set as your `baseUrl` is running:
> http://nginx:80
Your tests likely make requests to this `baseUrl` and these tests will fail if you do
n't boot your server.
Please start this server and then run Cypress again.
给它 http://localhost
也没有用。
我正在 运行ning 测试 运行ner 来自容器:docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.2.0
环境:
docker 版本 20.10.11,构建 dea9396
赛普拉斯 3.2.0
OS: Ubuntu Linux 20.04
如有任何建议,我们将不胜感激。
在这种情况下 运行ning Cypress 时,您必须使用 host network,因为如果您不使用相同的 docker network
,则无法从 cypress 访问 http://nginx:80
.您要么必须 运行 使用由 Docker 创建的相同网络,要么通过以下方式将 Cypress 容器网络组合或绑定到主机网络:
docker run -it -v $PWD:/e2e -w /e2e --network=host --ipc=host cypress/included:3.2.0
现在目标 localhost:80
而不是 nginx:80
。
我的容器都是 运行ning,我正在尝试 运行 Cypress 测试反对它:
docker-compose.yml:
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile
volumes:
- './services/users:/usr/src/app'
expose:
- 5000
environment:
- FLASK_APP=project/__init__.py
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgresql://postgres:postgres@users-db:5432/users_dev
- DATABASE_TEST_URL=postgresql://postgres:postgres@users-db:5432/users_test
- SECRET_KEY='hakuna matata'
depends_on:
- users-db
client:
build:
context: ./services/client
dockerfile: Dockerfile
volumes:
- './services/client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- 3007:3000
environment:
- CHOKIDAR_USEPOLLING=true
- NODE_ENV=development
- REACT_APP_USERS_SERVICE_URL=${REACT_APP_USERS_SERVICE_URL}
depends_on:
- users
users-db:
build:
context: ./services/users/project/db
dockerfile: Dockerfile
expose:
- 5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
nginx:
build:
context: ./services/nginx
dockerfile: Dockerfile
restart: always
ports:
- 80:80
depends_on:
- users
- client
cypress.json:
{
"baseUrl": "http://nginx:80",
"video": false
}
docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
97f91a4b3a81 tdd_nginx "/docker-entrypoint.…" 56 minutes ago Up 56 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp tdd_nginx_1
089cd20326c1 tdd_client "npm start" 56 minutes ago Up 56 minutes 0.0.0.0:3007->3000/tcp, :::3007->3000/tcp tdd_client_1
85dc333cc487 tdd_users "/usr/src/app/entryp…" 56 minutes ago Up 56 minutes 5000/tcp tdd_users_1
696298d0ab2c tdd_users-db "docker-entrypoint.s…" 56 minutes ago Up 56 minutes 5432/tcp tdd_users-db_1
错误输出:
Cypress could not verify that the server set as your `baseUrl` is running:
> http://nginx:80
Your tests likely make requests to this `baseUrl` and these tests will fail if you do
n't boot your server.
Please start this server and then run Cypress again.
给它 http://localhost
也没有用。
我正在 运行ning 测试 运行ner 来自容器:docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.2.0
环境:
docker 版本 20.10.11,构建 dea9396
赛普拉斯 3.2.0
OS: Ubuntu Linux 20.04
如有任何建议,我们将不胜感激。
在这种情况下 运行ning Cypress 时,您必须使用 host network,因为如果您不使用相同的 docker network
,则无法从 cypress 访问 http://nginx:80
.您要么必须 运行 使用由 Docker 创建的相同网络,要么通过以下方式将 Cypress 容器网络组合或绑定到主机网络:
docker run -it -v $PWD:/e2e -w /e2e --network=host --ipc=host cypress/included:3.2.0
现在目标 localhost:80
而不是 nginx:80
。