我希望创建一个Docker Compose文件来减少运行测试所需的命令数量。我的目标是运行一个命令,它将启动我的容器并运行我的测试。这是我第一次创建Docker Compose文件,请耐心等待。Docker Compose文件位于其他两个Docker文件旁边。下面是我启动的Docker Compose文件,但我甚至无法构建镜像。我尝试通过添加“volumes: - .:. ”来指定路径,但仍然不起作用。
services:
headless-chrome:
build: ./Dockerfile-headless-chrome
dev-server:
build: ./Dockerfile
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 68, in main
command()
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 118, in perform_command
handler(command, command_options)
File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 926, in up
scale_override=parse_scale_args(options['--scale']),
File "/usr/local/lib/python2.7/site-packages/compose/project.py", line 401, in up
svc.ensure_image_exists(do_build=do_build)
File "/usr/local/lib/python2.7/site-packages/compose/service.py", line 311, in ensure_image_exists
self.build()
File "/usr/local/lib/python2.7/site-packages/compose/service.py", line 888, in build
buildargs=build_args
File "/usr/local/lib/python2.7/site-packages/docker/api/build.py", line 137, in build
raise TypeError("You must specify a directory to build in path")
TypeError: You must specify a directory to build in path
version: "3"
为了运行测试,我通常会执行以下操作: Shell 1:
$ SCHEME=http ENV=stage DOCKER_DEV_ENTRYPOINT='"npm run dev-server"' make docker-dev
当这个正在运行时,我需要在新的shell(shell 2)中运行以下内容:
$ docker build -t headless-chrome -f Dockerfile-headless-chrome .
$ docker run -it --rm --net=host --cap-add=SYS_ADMIN headless-chrome /bin/bash
当我进入容器内时,我正在运行:
$ npm run selenium-docker
$ npm run uat