当我尝试安装jq时,我的构建过程总是失败。你能告诉我我做错了吗?
env:
parameter-store:
JWT_SECRET: JWT_SECRET
phases:
install:
runtime-versions:
python: 3.8
commands:
- curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator
- curl -sS -o kubectl https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/kubectl
- chmod +x ./kubectl ./aws-iam-authenticator
- export PATH=$PWD/:$PATH
- apt-get update && apt-get -y install jq
- apt-get -y install python3-pip python3-dev
- pip3 install --upgrade awscli
- pip3 install -r requirements.txt
# - pip3 install -r requirements.txt
- python3 -m pytest test_main.py
pre_build:
commands:
- TAG="$REPOSITORY_NAME.$REPOSITORY_BRANCH.$ENVIRONMENT_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- sed -i 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' simple_jwt_api.yml
- $(aws ecr get-login --no-include-email)
- export KUBECONFIG=$HOME/.kube/config
build:
commands:
- docker build --tag $REPOSITORY_URI:$TAG .
post_build:
commands:
- docker push $REPOSITORY_URI:$TAG
- CREDENTIALS=$(aws sts assume-role --role-arn $EKS_KUBECTL_ROLE_ARN --role-session-name codebuild-kubectl --duration-seconds 900)
- export AWS_ACCESS_KEY_ID="$(echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId')"
- export AWS_SECRET_ACCESS_KEY="$(echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey')"
- export AWS_SESSION_TOKEN="$(echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken')"
- export AWS_EXPIRATION=$(echo ${CREDENTIALS} | jq -r '.Credentials.Expiration')
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME
- kubectl apply -f simple_jwt_api.yml
- printf '[{"name":"simple_jwt_api","imageUri":"%s"}]' $REPOSITORY_URI:$TAG > build.json
- pwd
- ls
artifacts:
files: build.json
[容器] 2020/03/22 15:57:14等待代理ping
[容器] 2020/03/22 15:57:16等待DOWNLOAD_SOURCE
[容器] 2020/03/22 15:57:17阶段为DOWNLOAD_SOURCE
[容器] 2020/03/22 15:57:17 CODEBUILD_SRC_DIR = / codebuild / output / src534423531 / src
[容器] 2020/03/22 15:57:17 YAML位置是/codebuild/output/src534423531/src/buildspec.yml
[容器] 2020/03/22 15:57:17处理环境变量
[容器] 2020/03/22 15:57:17解密参数存储环境变量
[Container] 2020/03/22 15:57:17根据手动选择选择“ python”运行时版本“ 3.8” ...
[容器] 2020/03/22 15:57:17运行命令echo“正在安装python版本3.8 ...”
正在安装Python版本3.8 ...
[容器] 2020/03/22 15:57:17运行命令pyenv global $ PYTHON_38_VERSION
[容器] 2020/03/22 15:57:17移至目录/ codebuild / output / src534423531 / src
[容器] 2020/03/22 15:57:17向代理商注册
[容器] 2020/03/22 15:57:17 YAML中的阶段:4
[容器] 2020/03/22 15:57:17 POST_BUILD:11个命令
[容器] 2020/03/22 15:57:17安装:9个命令
[容器] 2020/03/22 15:57:17 PRE_BUILD:4个命令
[容器] 2020/03/22 15:57:17内置:1个命令
[容器] 2020/03/22 15:57:17完成阶段:DOWNLOAD_SOURCE状态:已成功
[容器] 2020/03/22 15:57:17阶段上下文状态代码:消息:
[容器] 2020/03/22 15:57:17进入安装阶段
[容器] 2020/03/22 15:57:17运行命令curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator
[容器] 2020/03/22 15:57:19运行命令curl -sS -o kubectl https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/kubectl [容器] 2020/03/22 15:57:19运行命令chmod + x ./kubectl ./aws-iam-authenticator
[容器] 2020/03/22 15:57:19运行命令export PATH = $ PWD /:$ PATH
[容器] 2020/03/22 15:57:19运行命令apt-get update && apt-get -y install jq
/codebuild/output/tmp/script.sh:第4行:apt-get:找不到命令
[容器] 2020/03/22 15:57:19命令未成功退出apt-get update && apt-get -y install jq退出状态127
[容器] 2020/03/22 15:57:19完成阶段:安装状态:失败
[容器] 2
答案 0 :(得分:0)
此行的问题很明显:
/codebuild/output/tmp/script.sh: line 4: apt-get: command not found
请使用Ubuntu 3.0 / 4.0映像,该映像将提供Python 3.8和'apt-get'命令。在Amazon Linux映像中,使用'yum'命令。
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html