Skip to content

Commit

Permalink
Merge pull request #121 from cjgarson/cjgarson-docker-datadirmount
Browse files Browse the repository at this point in the history
Add support to specify Docker bind mount path for nodes' NodeODM data directory & Update doc
  • Loading branch information
pierotofy authored Sep 19, 2024
2 parents b346016 + 27b9ac6 commit 9c1b83f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
11 changes: 9 additions & 2 deletions docs/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ the on-demand instance cost - you'll always pay the current market price, not yo
],

"addSwap": 1,
"dockerImage": "opendronemap/nodeodm"
"dockerImage": "opendronemap/nodeodm",
"dockerDataDirMountPath": ""
}
```

Expand All @@ -82,12 +83,14 @@ the on-demand instance cost - you'll always pay the current market price, not yo
| monitoring | Set to true to enable detailed Cloudwatch monitoring for the instance. |
| region | Region identifier where the instances should be created. |
| zone | Zone identifier where the instances should be created. |
| ami | The AMI (machine image) to launch this instance from. |
| ami | The AMI (machine image) to launch this instance from. Note that AMIs are region-specific. |
| engineInstallUrl | Specify installer for Docker engine. This can be cleared if AMI already has Docker engine installed. |
| tags | Comma-separated list of key,value tags to associate to the instance. |
| spot | Whether to request spot instances. If this is true, a `spotPrice` needs to be provided in the `imageSizeMapping`. |
| imageSizeMapping | Max images count to instance size mapping. (See below.) |
| addSwap | Optionally add this much swap space to the instance as a factor of total RAM (`RAM * addSwap`). A value of `1` sets a swapfile equal to the available RAM. |
| dockerImage | Docker image to launch |
| dockerDataDirMountPath | Path on node host to map to NodeODM data directory (/var/www/data). Use local instance storage for much faster I/O. |
| nodeSetupCmd | Can be optionally used to run a setup command on auto-scaled nodes right before we run ODM. |

## Image Size Mapping
Expand All @@ -103,3 +106,7 @@ instance able to process the requested number of images is always selected.
| slug | EC2 instance type to request (for example, `t3.medium`). |
| storage | Amount of storage to allocate to this instance's EBS root volume, in GB. |
| spotPrice | The maximum hourly price you're willing to bid for this instance (if spot instances are enabled). |

If `dockerDataDirMountPath` is specified and a local mount path is used for NodeODM's data directory (such as local NVMe storage on AWS 'd' instances),
the `storage` parameter here does not need to scale with image sizes and can be statically set lower. This is because the local NVMe storage will be used for temporary data
storage and not the instance's root EBS volume. However, it is important to ensure that the local storage size will be sufficient for the desired image count.
26 changes: 18 additions & 8 deletions libs/asr-providers/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{

"addSwap": 1,
"dockerImage": "opendronemap/nodeodm",
"dockerDataDirMountPath": "",
"iamrole": "",
"nodeSetupCmd": ""
}, userConfig);
Expand Down Expand Up @@ -120,6 +121,7 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
const dockerImage = this.getConfig("dockerImage");
const accessKey = this.getConfig("accessKey");
const secretKey = this.getConfig("secretKey");
const dataDirMountPath = this.getConfig("dataDirMountPath");
const s3 = this.getConfig("s3");
const webhook = netutils.publicAddressPath("/commit", req, token);

Expand All @@ -129,14 +131,22 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{
await dm.ssh(setupCmd);
}

await dm.ssh([`sudo docker run -d -p 3000:3000 ${dockerImage} -q 1`,
`--s3_access_key ${accessKey}`,
`--s3_secret_key ${secretKey}`,
`--s3_endpoint ${s3.endpoint}`,
`--s3_bucket ${s3.bucket}`,
`--s3_acl ${s3.acl}`,
`--webhook ${webhook}`,
`--token ${nodeToken}`].join(" "));
let dockerRunArgs = [`sudo docker run -d -p 3000:3000`];

if(dataDirMountPath.length > 0){
dockerRunArgs.push(`--mount type=bind,source=${dataDirMountPath},target=/var/www/data`);
}

dockerRunArgs.push(`${dockerImage} -q 1`);
dockerRunArgs.push(`--s3_access_key ${accessKey}`);
dockerRunArgs.push(`--s3_secret_key ${secretKey}`);
dockerRunArgs.push(`--s3_endpoint ${s3.endpoint}`);
dockerRunArgs.push(`--s3_bucket ${s3.bucket}`);
dockerRunArgs.push(`--s3_acl ${s3.acl}`);
dockerRunArgs.push(`--webhook ${webhook}`);
dockerRunArgs.push(`--token ${nodeToken}`);

await dm.ssh(dockerRunArgs.join(" "));
}

getImagePropertiesFor(imagesCount){
Expand Down

0 comments on commit 9c1b83f

Please sign in to comment.