Run Codebuild Image locally using Docker(Powershell Terminal)

0

The following command launches the container using the default buildspec.yml. The problem is making changes to the buildspec.yml are not reflected in subsequent calls. Deleted the containers/volumes does not refresh the execution with new contents.

I don't see any reference of running a codebuild locally on windows but trying to see if someone ran into the same problem.

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=myserver/docker-aws/codebuild/amazonlinux2-x86_64-standard:5.0" -e "ARTIFACTS=//Output" -e "SOURCE=//C/dev/codebuild" -e "LOCAL_AGENT_IMAGE_NAME=myserver/docker-aws/codebuild/local-builds:latest" -e "AWS_CONFIGURATION=//C/Users/username/.aws" -e "AWS_PROFILE=myprofile" myserver/docker-aws/codebuild/local-builds:latest
asked 13 days ago26 views
1 Answer
0

When running AWS CodeBuild locally using Docker on a Windows machine with PowerShell, there are a few things to consider to ensure that changes to your buildspec.yml file are reflected in subsequent builds.

First, make sure you're using the correct path format for Windows when specifying volume mounts. In PowerShell, you should use forward slashes (/) or escaped backslashes (\) for paths.

To address the issue of changes not being reflected, you can try the following:

  1. Ensure that you're mounting the correct directory containing your buildspec.yml file. In your command, you're mounting "//C/dev/codebuild" as the source. Make sure this path is correct and contains your updated buildspec.yml.

  2. Instead of relying on the default buildspec.yml, you can explicitly specify the buildspec file to use. Add the following environment variable to your docker run command:

    -e "BUILDSPEC=//C/path/to/your/buildspec.yml"

    This ensures that CodeBuild uses the specified buildspec file rather than looking for a default one.

  3. If you're still experiencing issues, you can try running the codebuild_build.sh script directly instead of using the Docker run command. This script is part of the CodeBuild agent and can be more flexible. You would need to download and run it from your local machine:

    ./codebuild_build.sh -i <container-image> -a <output directory>

Remember to replace <container-image> with your CodeBuild image and <output directory> with your desired output location.

By following these steps, you should be able to see changes in your buildspec.yml reflected in subsequent builds when running CodeBuild locally on Windows using Docker.
Sources
Run builds locally with the AWS CodeBuild agent - AWS CodeBuild

profile picture
answered 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions