我尝试使用Docker Cloud自动将PR测试到my project。我已按如下方式设置构建规则:
Dockerfile:
FROM node:8.4.0-alpine ENV NODE_ENV=production WORKDIR /olimat/api COPY package.json package-lock.json ./ RUN npm install --quiet COPY ./public ./public COPY ./config ./config COPY ./src ./src CMD npm start
Dockerfile.dev:
FROM node:8.4.0-alpine WORKDIR /olimat/api COPY package.json package-lock.json ./ RUN npm install --quiet COPY ./public ./public COPY ./config ./config COPY ./src ./src COPY ./db ./db
搬运工-compose.test.yml:
version: '3.2' services: sut: build: context: ./ dockerfile: Dockerfile.dev command: npm test depends_on: - api environment: NODE_ENV: test api: build: context: ./ dockerfile: Dockerfile depends_on: - db db: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: dev123 image: postgres:9.6.4-alpine
使用
docker-compose -f docker-compose.test.yml run sut在本地运行测试一切正常:
在Docker Cloud上,测试运行,但似乎永远不会返回退出代码:
我在这里1小时46分钟后取消了。发生了什么?如何在运行测试后退出 sut 服务容器?
完整的构建日志:
Building in Docker Cloud's infrastructure... Cloning into '.'... Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts. Reset branch 'master' Your branch is up-to-date with 'origin/master'. Pulling cache layers for index.docker.io/unemat/olimat-backend:latest... Done! KernelVersion: 4.4.0-93-generic Arch: amd64 BuildTime: 2017-08-17T22:50:04.828747906+00:00 ApiVersion: 1.30 Version: 17.06.1-ce MinAPIVersion: 1.12 GitCommit: 874a737 Os: linux GoVersion: go1.8.3 Starting build of index.docker.io/unemat/olimat-backend:latest... Step 1/9 : FROM node:8.4.0-alpine ---> 016382f39a51 Step 2/9 : ENV NODE_ENV production ---> Running in b0aa12f6d329 ---> 8c0420481faa Removing intermediate container b0aa12f6d329 Step 3/9 : WORKDIR /olimat/api ---> 669997c76951 Removing intermediate container b9344977ce13 Step 4/9 : COPY package.json package-lock.json ./ ---> 562fb1b9d9db Removing intermediate container 3778fb63cd12 Step 5/9 : RUN npm install --quiet ---> Running in 459a90d4ce4f > uws@0.14.5 install /olimat/api/node_modules/uws > node-gyp rebuild > build_log.txt 2>&1 || exit 0 added 261 packages in 19.34s ---> a22bd7c951bd Removing intermediate container 459a90d4ce4f Step 6/9 : COPY ./public ./public ---> 3555f3f71011 Removing intermediate container f6343f447c14 Step 7/9 : COPY ./config ./config ---> ffebbe0eae44 Removing intermediate container 1b6a25d1b044 Step 8/9 : COPY ./src ./src ---> ae66609e0177 Removing intermediate container a139a0a67b34 Step 9/9 : CMD npm start ---> Running in b1bc735877c5 ---> fba69367a862 Removing intermediate container b1bc735877c5 Successfully built fba69367a862 Successfully tagged unemat/olimat-backend:latest Starting Test in docker-compose.test.yml... db uses an image, skipping Building api Step 1/9 : FROM node:8.4.0-alpine ---> 016382f39a51 Step 2/9 : ENV NODE_ENV production ---> Using cache ---> 8c0420481faa Step 3/9 : WORKDIR /olimat/api ---> Using cache ---> 669997c76951 Step 4/9 : COPY package.json package-lock.json ./ ---> Using cache ---> 562fb1b9d9db Step 5/9 : RUN npm install --quiet ---> Using cache ---> a22bd7c951bd Step 6/9 : COPY ./public ./public ---> Using cache ---> 3555f3f71011 Step 7/9 : COPY ./config ./config ---> Using cache ---> ffebbe0eae44 Step 8/9 : COPY ./src ./src ---> Using cache ---> ae66609e0177 Step 9/9 : CMD npm start ---> Using cache ---> fba69367a862 Successfully built fba69367a862 Successfully tagged bs3klcfwuijavr4uf4daf28_api:latest Building sut Step 1/9 : FROM node:8.4.0-alpine ---> 016382f39a51 Step 2/9 : MAINTAINER Josias Iquabius ---> Running in ed1306bea19a ---> 5956fb44e0cc Removing intermediate container ed1306bea19a Step 3/9 : WORKDIR /olimat/api ---> be7fd8615cd4 Removing intermediate container 2bde5cfe6bdd Step 4/9 : COPY package.json package-lock.json ./ ---> b68a99364f80 Removing intermediate container d0f4715b4774 Step 5/9 : RUN npm install --quiet ---> Running in f9f053df7774 > uws@0.14.5 install /olimat/api/node_modules/uws > node-gyp rebuild > build_log.txt 2>&1 || exit 0 added 666 packages in 32.983s ---> 8f2ace5a6f9e Removing intermediate container f9f053df7774 Step 6/9 : COPY ./public ./public ---> 0cac78c670e2 Removing intermediate container ab0f50cbc747 Step 7/9 : COPY ./config ./config ---> ce57c484d544 Removing intermediate container 126828beed7d Step 8/9 : COPY ./src ./src ---> 7cd682b0f4d9 Removing intermediate container 819d441c2307 Step 9/9 : COPY ./db ./db ---> 244561b4bc52 Removing intermediate container 1a80d8f935b4 Successfully built 244561b4bc52 Successfully tagged bs3klcfwuijavr4uf4daf28_sut:latest Creating network "bs3klcfwuijavr4uf4daf28_default" with the default driver Pulling db (postgres:9.6.4-alpine)... 9.6.4-alpine: Pulling from library/postgres Digest: sha256:5fd73de311d304caeb4f907d4f559d322805abc622e4baf5788c6a079ee5224e Status: Downloaded newer image for postgres:9.6.4-alpine Creating bs3klcfwuijavr4uf4daf28_db_1 ... Creating bs3klcfwuijavr4uf4daf28_db_1 Creating bs3klcfwuijavr4uf4daf28_db_1 ... done Creating bs3klcfwuijavr4uf4daf28_api_1 ... Creating bs3klcfwuijavr4uf4daf28_api_1 Creating bs3klcfwuijavr4uf4daf28_api_1 ... done Creating bs3klcfwuijavr4uf4daf28_sut_1 ... Creating bs3klcfwuijavr4uf4daf28_sut_1 Creating bs3klcfwuijavr4uf4daf28_sut_1 ... done npm info it worked if it ends with ok npm info using npm@5.3.0 npm info using node@v8.4.0 npm info lifecycle olimat-backend@0.0.1~pretest: olimat-backend@0.0.1 npm info lifecycle olimat-backend@0.0.1~test: olimat-backend@0.0.1 > olimat-backend@0.0.1 test /olimat/api > jest PASS src/services/questions/questions.test.js ● Console console.log src/models/questions.model.js:10 questions table does not exists! info: after: questions - Method: find PASS src/app.test.js Test Suites: 2 passed, 2 total Tests: 5 passed, 5 total Snapshots: 0 total Time: 6.505s Ran all test suites. Build canceled. ERROR: Build failed with exit code 3 Build in 'master:/api' (4eeca024) canceled after 1:46:31