【问题标题】:aws code-build fails on build stepaws code-build 在构建步骤中失败
【发布时间】:2017-11-29 00:04:13
【问题描述】:

您好,几个月以来我一直在 aws 上运行 aws 代码管道。从星期一开始,我收到了这个错误:

[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_build.sh

#!/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_install.sh

#!/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_prebuild.sh

#!/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"

【问题讨论】:

  • 您可能需要在 docker 镜像中升级 aws-cli:pip install --upgrade awscli .. 您也可以查看this thread
  • 我在 buildspec_install.sh 的什么地方运行它?
  • 我在上面添加了一些消息
  • @AbdennourTOUMI 有什么提示吗?
  • 这看起来像sbt docker:stage 命令没有发挥作用?

标签: amazon-web-services amazon-ec2 aws-codepipeline


【解决方案1】:

您无法构建 Docker 映像,因为您在 Dockerfile 中缺少 FROM 行。

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_build.sh

#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

【讨论】:

  • 我应该添加什么样的图像?我以前从未有过发件人行吗?
  • OK 看起来像两个问题,sbt install 看起来有错误。所以它不会创建目录。这是我在安装 SBT stackoverflow.com/questions/13711395/… 时发现的
  • 我更改了 SBT 安装。但是构建再次失败并出现同样的错误
  • 啊不,我现在得到了不同的错误:[Container] 2017/11/29 08:21:33 Running command chmod +x buildspec_build.sh && ./buildspec_build.sh Detected sbt version 0.13.11 Cannot find sbt launcher 0.13.11 Please download: From http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.11/sbt-launch.jar To /root/.sbt/.lib/0.13.11/sbt-launch.jar Sending build context to Docker daemon 197.6 kB Step 1 : EXPOSE 9000 Please provide a source image with from` 在提交之前`
  • SBT 现在可以工作了......再次......现在这条消息仍然存在:请在提交之前提供带有from 的源图像
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-27
  • 2018-01-04
  • 1970-01-01
  • 2022-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多