copilot-cli: docker version 18 in buildspec of test_commands gives 'Unknown runtime version'
Hello,
Today I upgraded from 1.20 to 1.27.0.
I use test_commands for some post deployment steps and that started failing.
The buildspec that fails is
version: 0.2
phases:
install:
runtime-versions:
docker: 18
build:
commands:
- yum install -y sudo && yum install -y expect
- wget https://ecs-cli-v2-release.s3.amazonaws.com/copilot-linux-v1.27.0
- mv ./copilot-linux-v1.27.0 ./copilot-linux
- chmod +x ./copilot-linux
- unbuffer ./copilot-linux svc exec -c "python manage.py collectstatic --no-input --skip-checks" -n app -e test --yes
- unbuffer ./copilot-linux svc exec -c "python manage.py migrate" -n app -e test --yes
The error I’m getting with that:
[Container] 2023/03/31 18:53:17 Waiting for agent ping
--
2 | [Container] 2023/03/31 18:53:18 Waiting for DOWNLOAD_SOURCE
3 | [Container] 2023/03/31 18:53:21 Phase is DOWNLOAD_SOURCE
4 | [Container] 2023/03/31 18:53:21 CODEBUILD_SRC_DIR=/codebuild/output/src759560563/src
5 | [Container] 2023/03/31 18:53:21 YAML location is /codebuild/readonly/buildspec.yml
6 | [Container] 2023/03/31 18:53:21 No commands found for phase name: install
7 | [Container] 2023/03/31 18:53:21 Setting HTTP client timeout to higher timeout for S3 source
8 | [Container] 2023/03/31 18:53:21 Processing environment variables
9 | [Container] 2023/03/31 18:53:21 Selecting 'docker' runtime version '18' based on manual selections...
10 | [Container] 2023/03/31 18:53:24 Phase complete: DOWNLOAD_SOURCE State: FAILED
11 | [Container] 2023/03/31 18:53:24 Phase context status code: YAML_FILE_ERROR Message: Unknown runtime version named '18' of docker. This build image has the following versions: 20
Seems like it sets docker version 18 in the buildspec whereas version 20 is available in the build image.
Comparing that to the generated buildspec for the build stage generated by v1.27.0 that also sets docker to 20 like so:
version: 0.2
phases:
install:
runtime-versions:
docker: 20
ruby: 3.1
nodejs: 16
I did run copilot pipeline update
and all the changes for updating to v1.27.0 are committed to main.
Manually changing the buildspec of the build project to use docker: 20
solves the issue with logging:
[Container] 2023/03/31 20:13:20 Waiting for agent ping
--
2 | [Container] 2023/03/31 20:13:21 Waiting for DOWNLOAD_SOURCE
3 | [Container] 2023/03/31 20:13:25 Phase is DOWNLOAD_SOURCE
4 | [Container] 2023/03/31 20:13:25 CODEBUILD_SRC_DIR=/codebuild/output/src591659411/src
5 | [Container] 2023/03/31 20:13:25 YAML location is /codebuild/readonly/buildspec.yml
6 | [Container] 2023/03/31 20:13:25 No commands found for phase name: install
7 | [Container] 2023/03/31 20:13:25 Setting HTTP client timeout to higher timeout for S3 source
8 | [Container] 2023/03/31 20:13:25 Processing environment variables
9 | [Container] 2023/03/31 20:13:25 Selecting 'docker' runtime version '20' based on manual selections...
10 | [Container] 2023/03/31 20:13:25 Running command echo "Specifying docker version in buildspec is deprecated. Using docker $DOCKER_VERSION"
11 | Specifying docker version in buildspec is deprecated. Using docker 20.10.22
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
@efekarakus Sorry for the confusion, I am still getting the original error:
Sorry that I am still a bit unclear. It would be great if you could help clarify the following statements again.
1) There is a buildspec.yml in
copilot/pipelines/repo-main/buildspec.yml
—> This file has NOdocker
entry (it had a old ruby version that I had to update to 3.1) —> This buildspec appears to be the buildspec that CodeBuild is pointing to. —> Question: Based on what you said earlier “the buildspec.yml for test_commands isn’t written to the disk”, so this is NOT the buildspec I should edit?If that is not the buildspec I should be editing… —> Question: Where can I find the correct buildpsec that I should be editing?
If that is the correct buildspec… ----> Question: Why is it complaining about
docker: 18
when the entry is not in it? ----> Manually addingdocker: 20
does not help.For reference, the
buildspec.yml
generated by copilot incopilot/pipelines/repo-main/buildspec.yml
Hi @lennertcc !!
Thank you so much for reporting this issue. It looks like we have to update this section of the CloudFormation template for the pipeline: https://github.com/aws/copilot-cli/blob/e1afe3976229284a680ae59d6be4b6a6dd0478b5/internal/pkg/template/templates/cicd/pipeline_cfn.yml#L302-L304
and completely remove
docker
inruntime-versions
as its no longer needed to specifyI figured out why I got the YAML file missing error, it is because when I was trying to edit the buildspec, I accidentially deleted the path to the YAML file.
This is the original config by
copilot pipeline
. It appears to point the buildspec.yml that is generated, but you were saying that that is not the buildspec to modify?To recap, the file
copilot/pipelines/repo-main/buildspec.yml
that is originally generated does not havedocker: 18
in the runtime-versions. Addingdocker: 20
does not help either.