@@ -288,7 +288,8 @@ public function handle(): void
288288 // Make sure the private key is stored in the filesystem
289289 $ this ->server ->privateKey ->storeInFileSystem ();
290290 // Generate custom host<->ip mapping
291- $ allContainers = instant_remote_process (["docker network inspect {$ this ->destination ->network } -f '{{json .Containers}}' " ], $ this ->server );
291+ $ safeNetwork = escapeshellarg ($ this ->destination ->network );
292+ $ allContainers = instant_remote_process (["docker network inspect {$ safeNetwork } -f '{{json .Containers}}' " ], $ this ->server );
292293
293294 if (! is_null ($ allContainers )) {
294295 $ allContainers = format_docker_command_output_to_json ($ allContainers );
@@ -2015,9 +2016,11 @@ private function prepare_builder_image(bool $firstTry = true)
20152016 $ runCommand = "docker run -d --name {$ this ->deployment_uuid } {$ env_flags } --rm -v {$ this ->serverUserHomeDir }/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$ helperImage }" ;
20162017 } else {
20172018 if ($ this ->dockerConfigFileExists === 'OK ' ) {
2018- $ runCommand = "docker run -d --network {$ this ->destination ->network } --name {$ this ->deployment_uuid } {$ env_flags } --rm -v {$ this ->serverUserHomeDir }/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$ helperImage }" ;
2019+ $ safeNetwork = escapeshellarg ($ this ->destination ->network );
2020+ $ runCommand = "docker run -d --network {$ safeNetwork } --name {$ this ->deployment_uuid } {$ env_flags } --rm -v {$ this ->serverUserHomeDir }/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$ helperImage }" ;
20192021 } else {
2020- $ runCommand = "docker run -d --network {$ this ->destination ->network } --name {$ this ->deployment_uuid } {$ env_flags } --rm -v /var/run/docker.sock:/var/run/docker.sock {$ helperImage }" ;
2022+ $ safeNetwork = escapeshellarg ($ this ->destination ->network );
2023+ $ runCommand = "docker run -d --network {$ safeNetwork } --name {$ this ->deployment_uuid } {$ env_flags } --rm -v /var/run/docker.sock:/var/run/docker.sock {$ helperImage }" ;
20212024 }
20222025 }
20232026 if ($ firstTry ) {
@@ -3046,28 +3049,29 @@ private function build_image()
30463049 $ this ->execute_remote_command ([executeInDocker ($ this ->deployment_uuid , 'rm ' .self ::NIXPACKS_PLAN_PATH ), 'hidden ' => true ]);
30473050 } else {
30483051 // Dockerfile buildpack
3052+ $ safeNetwork = escapeshellarg ($ this ->destination ->network );
30493053 if ($ this ->dockerSecretsSupported ) {
30503054 // Modify the Dockerfile to use build secrets
30513055 $ this ->modify_dockerfile_for_secrets ("{$ this ->workdir }{$ this ->dockerfile_location }" );
30523056 $ secrets_flags = $ this ->build_secrets ? " {$ this ->build_secrets }" : '' ;
30533057 if ($ this ->force_rebuild ) {
3054- $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build --no-cache {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location }{$ secrets_flags } --progress plain -t $ this ->build_image_name {$ this ->workdir }" );
3058+ $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build --no-cache {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location }{$ secrets_flags } --progress plain -t $ this ->build_image_name {$ this ->workdir }" );
30553059 } else {
3056- $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location }{$ secrets_flags } --progress plain -t $ this ->build_image_name {$ this ->workdir }" );
3060+ $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location }{$ secrets_flags } --progress plain -t $ this ->build_image_name {$ this ->workdir }" );
30573061 }
30583062 } elseif ($ this ->dockerBuildkitSupported ) {
30593063 // BuildKit without secrets
30603064 if ($ this ->force_rebuild ) {
3061- $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build --no-cache {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location } --progress plain -t $ this ->build_image_name {$ this ->build_args } {$ this ->workdir }" );
3065+ $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build --no-cache {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location } --progress plain -t $ this ->build_image_name {$ this ->build_args } {$ this ->workdir }" );
30623066 } else {
3063- $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location } --progress plain -t $ this ->build_image_name {$ this ->build_args } {$ this ->workdir }" );
3067+ $ build_command = $ this ->wrap_build_command_with_env_export ("DOCKER_BUILDKIT=1 docker build {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location } --progress plain -t $ this ->build_image_name {$ this ->build_args } {$ this ->workdir }" );
30643068 }
30653069 } else {
30663070 // Traditional build with args
30673071 if ($ this ->force_rebuild ) {
3068- $ build_command = $ this ->wrap_build_command_with_env_export ("docker build --no-cache {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location } {$ this ->build_args } -t $ this ->build_image_name {$ this ->workdir }" );
3072+ $ build_command = $ this ->wrap_build_command_with_env_export ("docker build --no-cache {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location } {$ this ->build_args } -t $ this ->build_image_name {$ this ->workdir }" );
30693073 } else {
3070- $ build_command = $ this ->wrap_build_command_with_env_export ("docker build {$ this ->buildTarget } --network {$ this -> destination -> network } -f {$ this ->workdir }{$ this ->dockerfile_location } {$ this ->build_args } -t $ this ->build_image_name {$ this ->workdir }" );
3074+ $ build_command = $ this ->wrap_build_command_with_env_export ("docker build {$ this ->buildTarget } --network {$ safeNetwork } -f {$ this ->workdir }{$ this ->dockerfile_location } {$ this ->build_args } -t $ this ->build_image_name {$ this ->workdir }" );
30713075 }
30723076 }
30733077 $ base64_build_command = base64_encode ($ build_command );
0 commit comments