Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Circleci 2.0基于Dockerfile的构建_Docker_Circleci - Fatal编程技术网

Circleci 2.0基于Dockerfile的构建

Circleci 2.0基于Dockerfile的构建,docker,circleci,Docker,Circleci,我有一个Node.JS应用程序,我想使用CircleCI和Amazon ECR构建和测试它。文档中不清楚如何从存储库中的Dockerfile构建映像。我看了这里,也看了这里,但不清楚我在遗嘱执行人下面放了什么。以下是到目前为止我得到的信息: version: 2 jobs: build: docker: steps: - checkout - setup_remote_docker: version: 17.05.0-c

我有一个Node.JS应用程序,我想使用CircleCI和Amazon ECR构建和测试它。文档中不清楚如何从存储库中的Dockerfile构建映像。我看了这里,也看了这里,但不清楚我在遗嘱执行人下面放了什么。以下是到目前为止我得到的信息:

version: 2
jobs:
  build:
    docker:
    steps:
        - checkout
        - setup_remote_docker:
            version: 17.05.0-ce
        # build the image
        - run: docker build -t $ECR_REPO:0.1 .
CircleCI失败,出现以下错误:

* The job has no executor type specified. The job should have one of the following keys specified: "machine", "docker", "macos"

基本图像取自Dockerfile。我使用的是CircleCI内置的AWS集成,所以我不认为我需要添加AWS_auth。我需要在executor下放置什么才能运行此操作?

在Docker配置中使用Docker构建此操作:

version: 2
jobs:
  build:
    working_directory: /app
    docker:
      - image: docker:17.05.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py-pip=9.0.0-r1 gcc \
              libffi-dev python-dev \
              linux-headers \
              musl-dev \
              libressl-dev \
              make
            pip install \
              docker-compose==1.12.0 \
              awscli==1.11.76 \
              ansible==2.4.2.0
      - run:
          name: Save Vault Password to File
          command: echo $ANSIBLE_VAULT_PASS > .vault-pass.txt
      - run:
          name: Decrypt .env
          command: |
            ansible-vault decrypt .circleci/envs --vault-password-file .vault-pass.txt
      - run:
          name: Move .env
          command: rm -f .env && mv .circleci/envs .env
      - restore_cache:
          keys:
            - v1-{{ .Branch }}
          paths:
            - /caches/app.tar
      - run:
          name: Load Docker image layer cache
          command: |
            set +o pipefail
            docker load -i /caches/app.tar | true
      - run:
          name: Build application Docker image
          command: |
            docker build --cache-from=app -t app .
      - run:
          name: Save Docker image layer cache
          command: |
            mkdir -p /caches
            docker save -o /caches/app.tar app
      - save_cache:
          key: v1-{{ .Branch }}-{{ epoch }}
          paths:
            - /caches/app.tar
      - deploy:
          name: Push application Docker image
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              login="$(aws ecr get-login --region $ECR_REGION)"
              ${login}
              docker tag app "${ECR_ENDPOINT}:${CIRCLE_SHA1}"
              docker push "${ECR_ENDPOINT}:${CIRCLE_SHA1}"
            fi

您首先需要为构建指定一个Docker映像以运行。这应该起作用:

version: 2
jobs:
  build:
    docker:
      - image: docker:stable-git
    steps:
      - checkout
      - setup_remote_docker:
          version: 17.05.0-ce
      # build the image
      - run: docker build -t $ECR_REPO:0.1 .

插入舞蹈表情!!非常感谢。