代码之家  ›  专栏  ›  技术社区  ›  Felix

aws代码生成在生成步骤失败

  •  2
  • Felix  · 技术社区  · 7 年前

    [Container] 2017/11/16 14:46:37 Running command chmod +x buildspec_prebuild.sh && ./buildspec_prebuild.sh
    Flag --email has been deprecated, will be removed in 1.13.
    Login Succeeded
    {
    "failures": [
    {
    "failureReason": "Requested image not found", 
    "failureCode": "ImageNotFound", 
    "imageId": {
    "imageTag": "approval-machine-processes"
    }
    }
    ], 
    "imageIds": []
    }
    
    [Container] 2017/11/16 14:46:40 Phase complete: PRE_BUILD Success: true
    [Container] 2017/11/16 14:46:40 Phase context status code: Message: 
    [Container] 2017/11/16 14:46:40 Entering phase BUILD
    [Container] 2017/11/16 14:46:40 Running command echo "*** BUILD:"
    *** BUILD:
    
    [Container] 2017/11/16 14:46:40 Running command chmod +x buildspec_build.sh && ./buildspec_build.sh
    /usr/share/sbt/bin/sbt-launch-lib.bash: line 207: bc: command not found
    

    在这种情况下会出现什么问题?

    我的生成文件如下所示:

    buildspec\u构建。上海

    #!/bin/bash
    
    # make code ready for docker
    sbt docker:stage
    cd target/docker/stage
    
    # add port for aws to dockerfile
    echo "EXPOSE 9000" >> Dockerfile
    
    # generate docker image tag
    docker build -t "$(cat /tmp/build_tag.out)" .
    

    aws有什么变化吗? 提前感谢

    更新:

    这里有更多信息:

    ./buildspec_build.sh: line 5: cd: target/docker/stage: No such file or directory
    Sending build context to Docker daemon 194.6 kB
    
    Step 1 : EXPOSE 9000
    Please provide a source image with `from` prior to commit
    
    [Container] 2017/11/16 15:23:13 Command did not exit successfully chmod +x buildspec_build.sh && ./buildspec_build.sh exit status 1
    [Container] 2017/11/16 15:23:13 Phase complete: BUILD Success: false
    [Container] 2017/11/16 15:23:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: chmod +x buildspec_build.sh && ./buildspec_build.sh. Reason: exit status 1
    [Container] 2017/11/16 15:23:13 Entering phase POST_BUILD
    [Container] 2017/11/16 15:23:13 Running command echo "*** POST-BUILD:"
    *** POST-BUILD:
    
    [Container] 2017/11/16 15:23:13 Running command chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh
    The push refers to a repository [.dkr.ecr.eu-central-1.amazonaws.com/......]
    An image does not exist locally with the tag:
    

    更新:

    buildspec。yml公司

    version: 0.1
    phases:
      install:
        commands:
          - echo "*** INSTALL:"
          - chmod +x buildspec_install.sh && ./buildspec_install.sh
      pre_build:
        commands:
          - echo "*** PRE-BUILD:"
          - chmod +x buildspec_prebuild.sh && ./buildspec_prebuild.sh
      build:
        commands:
          - echo "*** BUILD:"
          - chmod +x buildspec_build.sh && ./buildspec_build.sh
      post_build:
        commands:
          - echo "*** POST-BUILD:"
          - chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh
    

    buildspec\u安装。上海

    #!/bin/bash
    apt-get update
    
    # install jdk
    apt-get -y install software-properties-common
    apt-get -y install -y python-software-properties debconf-utils
    add-apt-repository -y ppa:openjdk-r/ppa
    apt-get update
    apt-get -y install openjdk-8-jdk
    update-alternatives --config java
    update-alternatives --config javac
    echo "java installation ok"
    
    # install sbt
    apt-get update
    apt-get -y install apt-transport-https
    echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
    apt-get update
    apt-get -y install sbt
    echo "sbt installation ok"
    
    pip install --upgrade awscli
    

    buildspec\u预构建。上海

    #!/bin/bash
    printf "%s:%s" "$REPOSITORY_URI" "$IMAGE_TAG" > /tmp/build_tag.out
    $(aws ecr get-login)
    
    # delete old docker image
    aws ecr batch-delete-image --repository-name $REPOSITORY_NAME --image-ids imageTag=$IMAGE_TAG
    
    echo "old docker images"
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   strongjz    7 年前

    由于缺少一个 FROM Dockerfile中的行。

    http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html

    "failures": [
    {
    "failureReason": "Requested image not found", 
    "failureCode": "ImageNotFound", 
    "imageId": {
    "imageTag": "approval-machine-processes"
    }
    }
    ], 
    "imageIds": []
    }
    

    从…起

    Step 1 : EXPOSE 9000
    Please provide a source image with `from` prior to commit
    

    从buildspec\u构建。上海

    #add port for aws to dockerfile 
    echo "EXPOSE 9000" >> Dockerfile
    

    SBT安装中的错误不会导致Docker生成。

    [Container] 2017/11/16 14:46:40 Running command chmod +x buildspec_build.sh && ./buildspec_build.sh
    /usr/share/sbt/bin/sbt-launch-lib.bash: line 207: bc: command not found