Comments (7)
For our builds we need the code path mounted at minimum. I was able to resolve this by referencing the volume directly in compose, so we now have:
volumes: - /var/lib/docker/volumes/agent-resources_user_volume/_data/srcDownload/src:/src
This is an ok-ish workaround for us for now, but we would like to see this implemented in a more intuitive/native way as we now have to parameterize a bunch of low level things to test builds locally which kind of blows the whole point of being able to build locally.
This doesn't seem to work for me. the agent-resources_user_volume
volume's src
directory on the host is always empty when I run codebuild_build.sh
. As a workaround, I've set an extra variable in my local environment file so the build knows when it's running in a local codebuild, and I have a script that populates the path on the host before running Codebuild. When running remotely, it will get the path from inside the Codebuild container.
codebuild.env.template
:
LOCAL_CODEBUILD=true
SOURCE_DIR=${SOURCE_DIR}
run_local_codebuild.sh
:
#/bin/bash
# Resolve source directory on the host because the local Codebuild agent uses the host's Docker daemon
sed "s|\${SOURCE_DIR}|/path/to/src/on/host|" codebuild.env.template > codebuild.env
# Run Codebuild locally
codebuild_build.sh -i aws/codebuild/standard:5.0 -s /path/to/src/on/host -e codebuild.env
buildspec.yaml
:
...
phases:
build:
- |
if [ ! "${LOCAL_CODEBUILD}" = true ]
then
SOURCE_DIR="/path/to/src/in/container"
fi
...
from aws-codebuild-docker-images.
Hi @piotrkubisa,
You're correct in that the host's docker.sock
is being mounted in the guest container. This allows Docker builds to take advantage of the host's Docker layer cache, preserving intermediate layers between local builds, instead of losing them whenever the guest container terminates.
The tradeoff is that directories from the guest container cannot be mounted via docker run
, because the mount paths are resolved on the host, not in the container, as you've noted.
We've filed this as a feature request for the ability to choose between the two behaviors. Thanks for reporting this!
from aws-codebuild-docker-images.
Any update (or workarounds) on this one? I have similar requirement to the OP.
from aws-codebuild-docker-images.
@micklove I guess you could just change the following line (remove volume share to docker.sock
between host and guest) and run your modified shell script:
Edit: My bad, it won't work, because it will report problems with connecting to the docker service. I don't know any workaround to satisfy VOLUME [/var/lib/docker]
step... maybe exporting docker container (i.e. via docker image save amazon/aws-codebuild-local > local-cb.tar
) to copy /LocalBuild
contents and recreate image without that step will help (since image is not so complicated - docker history --no-trunc amazon/aws-codebuild-local
)?
from aws-codebuild-docker-images.
For our builds we need the code path mounted at minimum. I was able to resolve this by referencing the volume directly in compose, so we now have:
volumes:
- /var/lib/docker/volumes/agent-resources_user_volume/_data/srcDownload/src:/src
This is an ok-ish workaround for us for now, but we would like to see this implemented in a more intuitive/native way as we now have to parameterize a bunch of low level things to test builds locally which kind of blows the whole point of being able to build locally.
from aws-codebuild-docker-images.
FYI: For somebody still is interested in running a mimicked CodeBuild
locally, but wants more room to do some changes. Quite recently, I have updated the https://github.com/piotrkubisa/localcb to compute a docker
command (via using localcb run --dry-run
combo) based on input buildspec.yml
file and CLI arguments. I believe in that way, it is easier to customize and transparent in what is actually happening (as long as you don't need to use finally
in stages).
from aws-codebuild-docker-images.
I get an exit status 2 when i run - docker run -v $(pwd)/target:/zap/wrk/:rw -t owasp/zap2docker-stable zap-full-scan.py -t $url -g gen.conf -r report.html in codebuild. Has there been any workaround yet?
from aws-codebuild-docker-images.
Related Issues (20)
- Feature request: Python 3.12 support HOT 3
- docker error HOT 2
- Support podman in codebuild_build.sh
- Running aarch64 codebuild image on a x86_64 machine HOT 2
- No longer able to use "n 18.16.0" in build using aws/codebuild/amazonlinux2-x86_64-standard:5.0 HOT 9
- support dotnet version 8 HOT 2
- EMFILE and EBUSY errors in node 20 HOT 3
- [URGENT] Looking forward to add support for DotNET 8.0 in CodeBuild. HOT 1
- Python 3.12 runtime support HOT 1
- Add support for Node 20 in ARM images HOT 2
- PHP 8.3 Support HOT 4
- local CodeBuild does not seem to perform caching
- aws/codebuild/standard:7.0-24.1.13 and 23.12.14 failing Lambda layer Makefile SAM build
- Docker 25 support HOT 13
- Please update glibc
- Unable to run 'apt-get' on aws/codebuild/amazonlinux2-x86_64-standard:5.0 HOT 3
- Recent ARM image update has unintended side effects HOT 1
- Feature request: Golang 1.22 support HOT 1
- Add browsers to aws/codebuild/standard:7.0 HOT 1
- Amazon Linux:2023 image not available (CodeBuild, CodePipeline) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-codebuild-docker-images.