2

Hi I runned the aws code pipeline on aws since months now. Since monday I got this error:

[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

What could be the problem in this case?

my build files look like this:

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)" .

Has aws something changed? thanks in advance

UPDATE:

Here more messages:

./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:

UPDATE:

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"
Felix
  • 5,452
  • 12
  • 68
  • 163

1 Answers1

1

You could not build the Docker image since you missing a FROM line in the 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": []
}

From

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

From the buildspec_build.sh

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

Errors with the SBT install are not staging the Docker 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
strongjz
  • 4,271
  • 1
  • 17
  • 27
  • and what kind of image should I add? I've never had a from line before? – Felix Nov 28 '17 at 06:59
  • Ok looks like two problems, the sbt install looks like it has errors. so it doesnt create the directories. Here is what I found on install SBT https://stackoverflow.com/questions/13711395/install-sbt-on-ubuntu#13718915 – strongjz Nov 28 '17 at 16:02
  • I changed the SBT Install. But Build faills again with same error – Felix Nov 29 '17 at 09:23
  • Ah no I got different error now: `[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` prior to commit` – Felix Nov 29 '17 at 09:25
  • SBT works now ... again ... Now this message is remaining: Please provide a source image with `from` prior to commit – Felix Nov 29 '17 at 10:05