Skip to content

Commit f032615

Browse files
authored
Merge pull request #336 from awszhen/codebuild
Add option for supporting privileged build container
2 parents dcd0bd9 + f0912e4 commit f032615

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

local_builds/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Download and use our codebuild_build.sh script to run your local builds.
2929
-b Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory.
3030
-e Used to specify a file containing environment variables.
3131
-m Used to mount the source directory to the customer build container directly.
32+
-d Used to run the build container in docker privileged mode.
3233
-s Used to specify a source directory. Defaults to the current working directory.
3334
* First (-s) is for primary source
3435
* Use additional (-s) in `<sourceIdentifier>:<sourceLocation>` format for secondary source

local_builds/codebuild_build.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function usage {
4343
echo " -p Used to specify the AWS CLI Profile."
4444
echo " -b FILE Used to specify a buildspec override file. Defaults to buildspec.yml in the source directory."
4545
echo " -m Used to mount the source directory to the customer build container directly."
46+
echo " -d Used to run the build container in docker privileged mode."
4647
echo " -e FILE Used to specify a file containing environment variables."
4748
echo " (-e) File format expectations:"
4849
echo " * Each line is in VAR=VAL format"
@@ -57,14 +58,16 @@ image_flag=false
5758
artifact_flag=false
5859
awsconfig_flag=false
5960
mount_src_dir_flag=false
61+
docker_privileged_mode_flag=false
6062

61-
while getopts "cmi:a:s:b:e:l:p:h" opt; do
63+
while getopts "cmdi:a:s:b:e:l:p:h" opt; do
6264
case $opt in
6365
i ) image_flag=true; image_name=$OPTARG;;
6466
a ) artifact_flag=true; artifact_dir=$OPTARG;;
6567
b ) buildspec=$OPTARG;;
6668
c ) awsconfig_flag=true;;
6769
m ) mount_src_dir_flag=true;;
70+
d ) docker_privileged_mode_flag=true;;
6871
s ) source_dirs+=("$OPTARG");;
6972
e ) environment_variable_file=$OPTARG;;
7073
l ) local_agent_image=$OPTARG;;
@@ -160,6 +163,11 @@ then
160163
docker_command+=" -e \"MOUNT_SOURCE_DIRECTORY=TRUE\""
161164
fi
162165

166+
if $docker_privileged_mode_flag
167+
then
168+
docker_command+=" -e \"DOCKER_PRIVILEGED_MODE=TRUE\""
169+
fi
170+
163171
if isOSWindows
164172
then
165173
docker_command+=" -e \"INITIATOR=$USERNAME\""

0 commit comments

Comments
 (0)