У меня есть скрипт circleCI, в котором он запускает docker-compose exec postgres pg_isready
настройку команды в Azure контейнерах, но мы получаем ошибку сборки кода, как показано ниже. Раньше тот же сценарий работал нормально, но в последние несколько дней мы получаем это.
running docker-compose up
Creating network "docker_default" with the default driver
Pulling postgres (postgres:9.6)...
9.6: Pulling from library/postgres
Status: Downloaded newer image for postgres:9.6
Creating docker_myproject_1 ...
Creating docker_postgres_1 ...
waiting for postgres to startAttaching to docker_myproject_1
ERROR: No container found for postgres_1
myproject_1 | 2020-02-18T14:40:42.317723661Z starting...
.myproject_1 | 2020-02-18T14:40:43.718394751Z {"name":"myproject","hostname":"xxxxxx","pid":1,"level":30,"msg":"myproject app version v2.8 listening on port 3030 (Node.js version 8.17.0, ci environment)","time":"2020-02-18T14:40:43.717Z","v":0}
myproject_1 | 2020-02-18T14:40:43.718573206Z myproject app version v2.8 listening on port 3030 (Node.js version 8.17.0, ci environment)
myproject_1 | 2020-02-18T14:40:43.793220191Z Failed to prune sessions: getaddrinfo ENOTFOUND postgres postgres:5432
ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.ERROR: No container found for postgres_1
.Too many attempts
Файл конфигурации CircleCI --- config.yml
version: 2
jobs:
build:
working_directory: /home/circleci/app
docker:
- image: circleci/node:8-browsers
- image: circleci/postgres:9.6-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: myproject_ci
steps:
# Prepare build environment
- setup_remote_docker:
reusable: true
- checkout
- restore_cache:
key: dependency-cache-v2-{{ checksum "package.json" }}
# Install dependencies + cache them
- run: npm install
- save_cache:
key: dependency-cache-v2-{{ checksum "package.json" }}
paths:
- node_modules
# Build
- run: CONFIG_ENV=ci npm run build
# Start for testing
- run:
command: ./scripts/run-ci.sh
background: true
- run: ./scripts/run-ci-wait.sh
# Run tests
- run: CONFIG_ENV=ci npm test
# Run tests for docker image
- run: ./test/docker/run-docker-tests.sh
- deploy:
name: Deploy master to dev
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./scripts/deploy-dev.sh
fi
Содержимое run- docker -tests. sh там, где он терпит неудачу
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
function cleanup() {
docker-compose down || true
}
trap cleanup SIGINT SIGTERM EXIT
echo 'running docker-compose down'
docker-compose down
echo 'running docker-compose up'
docker-compose up -d --force-recreate
docker-compose logs --follow --timestamps --no-color myproject &
printf 'waiting for postgres to start'
attempt=0
until docker-compose exec postgres pg_isready; do
printf '.'
sleep 2
attempt=$(( $attempt + 1 ))
if [ $attempt -gt 15 ]; then
echo Too many attempts
exit 1
fi
done
echo 'postgres is started'
printf 'waiting for server to start'
attempt=0
until docker-compose run -T myproject curl --output /dev/null --silent --head --fail http://myproject:3030; do
printf '.'
sleep 2
attempt=$(( $attempt + 1 ))
if [ $attempt -gt 15 ]; then
echo Too many attempts
exit 1
fi
done
echo 'server is started'
Успешная сборка с использованием того же сценария на прошлой неделе.
Status: Downloaded newer image for postgres:9.6
Creating docker_postgres_1 ...
Creating docker_myproject_1 ...
waiting for postgres to startAttaching to docker_myproject_1
myproject_1 | 2020-02-14T14:57:56.436816113Z starting...
^@^@/var/run/postgresql:5432 - no response
myproject_1 | 2020-02-14T14:57:58.305638546Z {"name":"myproject","hostname":"xxxxxx","pid":1,"level":30,"msg":"myproject app version v2 listening on port 3030 (Node.js version 8.17.0, ci environment)","time":"2020-02-14T14:57:58.305Z","v":0}
myproject_1 | 2020-02-14T14:57:58.306243774Z myproject app version v2 listening on port 3030 (Node.js version 8.17.0, ci environment)
.myproject_1 | 2020-02-14T14:57:58.413266214Z Failed to prune sessions: connect ECONNREFUSED x.x.x.x:5432
/var/run/postgresql:5432 - no response
./var/run/postgresql:5432 - accepting connections
postgres is started
waiting for server to startserver is started
Создание файла
version: "3"
services:
myproject:
image: myproject:latest
environment:
- CONFIG_ENV=ci
- CONFIG_PASSWORD
- POSTGRES_HOST=postgres
postgres:
image: postgres:9.6
environment:
- POSTGRES_DB=myproject_ci
Любая помощь здесь будет отличной.