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

update docker build to fix #748 #749

Closed ozbillwang closed 4 years ago

ozbillwang commented 4 years ago

With exist Dockerfile, I can't run the demo properly. Issue has been reported in #748

After spend the weekend, I found the Dockerfile is going to wrong direction. This PR can drag it back on the right rail.

Changes include:

1) We should not include python source codes directly in Dockerfile, if it is not installed as python packages. 2) the installation pollutes the source codes, that's main reason we got problem #748 3) simpily the build process. 4) make AWS_DEFAULT_REGION as optional, so we can change it easly by adding --build-args with docker build command. In fact, I don't recommend to hardcode it when build, we can easily set it as enviroment variable when docker run it. 5) update README for part of docker run usage.

CLAassistant commented 4 years ago

CLA assistant check
All committers have signed the CLA.

ozbillwang commented 4 years ago

By the way, if you don't care the docker image size, below Dockerfile works directly

FROM python:3.7

COPY requirements.txt .
RUN pip install -r requirements.txt

EXPOSE 8000

build and run

$ docker build -t cloudmapper .

$ docker run -ti --rm -v $(pwd):/apps -p 8000:8000 -w /apps cloudmapper bash
root@478f234ece33:/apps# 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@478f234ece33:/apps# python cloudmapper.py report --config config.json.demo --account demo
* Getting resource counts
  - demo
* Getting IAM data
  - demo
* Getting public resource data
  - demo
* Auditing accounts
Report written to web/account-data/report.html
root@478f234ece33:/apps# python cloudmapper.py webserver --public
CloudMapper serving web directory on 0.0.0.0:8000

Now you can access it via http://localhost:8000

0xdabbad00 commented 4 years ago

These changes appear to be just a difference in opinion in how to use Docker. I personally do not think that the Dockerfile option should be used, but some people want it, and it works.

ozbillwang commented 4 years ago

@0xdabbad00

See my update in https://github.com/duo-labs/cloudmapper/issues/748#issuecomment-663938465

This PR is going to fix above issue, if you close it, your problem is still exist.