duo-labs / cloudmapper

CloudMapper helps you analyze your Amazon Web Services (AWS) environments.
BSD 3-Clause "New" or "Revised" License
5.96k stars 800 forks source link

Dockerfile doesn't work #748

Closed ozbillwang closed 4 years ago

ozbillwang commented 4 years ago
$ docker build -t cloudmapper . 

$ docker run -ti --rm cloudmapper bash 
root@7f0ad00a93e6:/opt/cloudmapper# python cloudmapper.py prepare --config config.json.demo --account demo
Building data for account demo (123456789012)
Traceback (most recent call last):
  File "cloudmapper.py", line 72, in <module>
    main()
  File "cloudmapper.py", line 66, in main
    commands[command].run(arguments)
  File "/opt/cloudmapper/commands/prepare.py", line 831, in run
    prepare(account, config, outputfilter)
  File "/opt/cloudmapper/commands/prepare.py", line 660, in prepare
    cytoscape_json = build_data_structure(account, config, outputfilter)
  File "/opt/cloudmapper/commands/prepare.py", line 419, in build_data_structure
    for region_json in get_regions(account, outputfilter):
  File "/opt/cloudmapper/shared/common.py", line 161, in get_regions
    regions = pyjq.all(".Regions[]{}".format(region_filter), region_data)
  File "/usr/local/lib/python3.7/site-packages/pyjq.py", line 49, in all
    return compile(script, vars, library_paths).all(_get_value(value, url, opener))
  File "_pyjq.pyx", line 209, in _pyjq.Script.all (_pyjq.c:2561)
_pyjq.ScriptRuntimeError: Cannot iterate over null (null)
root@7f0ad00a93e6:/opt/cloudmapper#
0xdabbad00 commented 4 years ago

This issue does not appear to be related to Docker.

ozbillwang commented 4 years ago

@0xdabbad00

It does.

Use the same image I build with exist Dockerfile, but I mount the repo to container (-v $(pwd):/opt/cloudmapper), it works.

Could you try it on your computer? this problem is easily duplicated

$ git clone git@github.com:duo-labs/cloudmapper.git
$ cd cloudmapper
$ docker build -t cloudmapper .

# doesn't work, that's the issue I reported here.
$ docker run -ti --rm cloudmapper bash 
root@3095bc277b04:/opt/cloudmapper# python cloudmapper.py prepare --config config.json.demo --account demo
....
....
_pyjq.ScriptRuntimeError: Cannot iterate over null (null)

# does work
$ docker run -ti --rm -v $(pwd):/opt/cloudmapper cloudmapper bash
root@fab09cf1fd9b:/opt/cloudmapper# python cloudmapper.py prepare --config config.json.demo --account demo
Building data for account demo (123456789012)
- 16 nodes built in region us-east-1
- 3 external CIDRs built
- 35 connections built
root@fab09cf1fd9b:/opt/cloudmapper#
mingfang commented 4 years ago

This issue does not appear to be related to Docker.

@0xdabbad00 I'm seeing exactly this same problem. What do you think is the problem?

mingfang commented 4 years ago

This issue does not appear to be related to Docker.

@0xdabbad00 I'm seeing exactly this same problem. What do you think is the problem?

I figured out the problem; I was missing the account-data/demo because .dockerignore prevented the account-data from getting added to the docker image(a good thing). To run the demo using docker, you must bind mount the account-data directory, e.g.

docker run --rm -it -p 8000:8000 -v `pwd`/account-data:/opt/cloudmapper/account-data  cloudmapper /bin/bash