oasis-open / cti-taxii-server

OASIS TC Open Repository: TAXII 2 Server Library Written in Python
https://medallion.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
120 stars 73 forks source link

Unable to run using docker and python command #180

Closed Aekansh-Ak closed 9 months ago

Aekansh-Ak commented 9 months ago

I used these commands:

docker run --rm -p 5000:5000 -v medallion/test/data:/var/taxii medallion docker run --rm -p 5000:5000 -v medallion/test/data: /var/taxii medallion docker run --rm -p 5000:5000 -v medallion/test/data/config.json:/var/taxii medallion They give error.

This command runs, but I don't see any container created when I do docker ps-: docker run --rm -p 5000:5000 -v medallion/test/data/config.json/var/taxii medallion

Using Python: I tried both commands.

python medallion/scripts/run.py python medallion/scripts/run.py --conf-file medallion/test/data/config.json

I get this error: python medallion/scripts/run.py Traceback (most recent call last): File "medallion/scripts/run.py", line 10, in from medallion.common import ( ImportError: cannot import name 'APPLICATION_INSTANCE'

I checked in site-packages where medallion is installed this is missing "APPLICATION_INSTANCE = Flask("medallion") but it is in common.py in github but not when you do pip install medallion, I changed it but there are just errors one after the other.

It will be easier I guess if this can be done using docker.

chisholm commented 9 months ago

It might be helpful to know how you obtained/installed medallion.

For commandline usage from a git clone, starting with a fresh virtualenv:

$ git clone https://github.com/oasis-open/cti-taxii-server.git
$ cd cti-taxii-server/
$ pip install -e .
$ medallion -c ./sample-config-with-memory-backend.json
Skipping import of 'mongodb_backend' backend: No module named 'pymongo'
 * Serving Flask app 'medallion'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit

I don't get the same behavior you do.

Running from a pypi installation is harder, since you need a config file and the ones on the master branch don't work. I think the pypi version is pretty old. Probably better off running from a git clone.

Edit: I guess you don't need to install medallion in editable mode... I am used to it and did it without thinking. :)

Edit again: with respect to docker, a docker compose file is provided, which you might try:

$ git clone https://github.com/oasis-open/cti-taxii-server.git
$ cd cti-taxii-server/
$ docker compose up

That seemed to work to build a medallion image and bring up the server with a mongo backend. Perhaps that will work for you?

Aekansh-Ak commented 9 months ago

Thank you so much, it worked.