|
| 1 | +============= |
| 2 | +Docker |
| 3 | +============= |
| 4 | + |
| 5 | +.. highlight:: sh |
| 6 | + |
| 7 | +OpenTAXII can also be run using docker. This guide assumes that you have access to a local or remote docker server, and won't go into the setup of docker. |
| 8 | + |
| 9 | +To get a default (development) instance using docker |
| 10 | + |
| 11 | + |
| 12 | +.. code-block:: shell |
| 13 | +
|
| 14 | + docker run -d -p 9000:9000 intelworks/opentaxii |
| 15 | +
|
| 16 | +.. note:: |
| 17 | + |
| 18 | + OpenTAXII is now accessible through port 9000, and is not configured. |
| 19 | + |
| 20 | +Extending |
| 21 | +==================== |
| 22 | + |
| 23 | +A better way using the OpenTAXII docker image, is to extend it, and create the custom configuration on startup. An example of is can be found `examples/Dockerfile <https://raw.githubusercontent.com/Intelworks/OpenTAXII/master/examples/Dockerfile>`_. Here the the configuration is replaced by an instance using MySQL. |
| 24 | + |
| 25 | +.. code-block:: docker |
| 26 | +
|
| 27 | + FROM intelworks/opentaxii:latest |
| 28 | + |
| 29 | +
|
| 30 | + RUN pip install mysql-python |
| 31 | +
|
| 32 | + COPY services.yml /services.yml |
| 33 | + COPY collections.yml /collections.yml |
| 34 | + COPY docker-entrypoint.sh /entrypoint.sh |
| 35 | +
|
| 36 | + ENV OPENTAXII_AUTH_SECRET "SOME SECRET" |
| 37 | + ENV OPENTAXII_DOMAIN "localhost:9000" |
| 38 | + ENV OPENTAXII_USER "" |
| 39 | + ENV OPENTAXII_PASS "" |
| 40 | + ENV DB_USER "" |
| 41 | + ENV DB_PASS "" |
| 42 | + ENV DB_NAME "" |
| 43 | + ENV DB_HOST "" |
| 44 | + ENV DB_PORT "" |
| 45 | +
|
| 46 | + ENTRYPOINT ["./entrypoint.sh"] |
| 47 | + CMD [ "supervisord","-c","/supervisord.conf" ] |
| 48 | +
|
| 49 | +
|
| 50 | +Using this configuration it is possible to add a new `/opentaxii.yml` configuration, which in this case is generated by the `entrypoint.sh` script. Furthermore it adds the example `services.yml` and `collections.yml` to the image. |
| 51 | + |
| 52 | +To see this in action, you can use the `docker-compose <https://docs.docker.com/compose/>`_ tool to run a complete working setup using mysql. The configuration is located at: `examples/docker-compose.yml <https://raw.githubusercontent.com/Intelworks/OpenTAXII/master/examples/docker-compose.yml>`_ |
| 53 | + |
| 54 | +.. code-block:: yaml |
| 55 | +
|
| 56 | + db: |
| 57 | + image: mysql |
| 58 | + environment: |
| 59 | + MYSQL_USER: user |
| 60 | + MYSQL_PASSWORD: password |
| 61 | + MYSQL_DATABASE: opentaxii |
| 62 | + MYSQL_ROOT_PASSWORD: pass |
| 63 | + ports: |
| 64 | + - 3306:3306 |
| 65 | +
|
| 66 | + opentaxii: |
| 67 | + build: . |
| 68 | + environment: |
| 69 | + OPENTAXII_AUTH_SECRET: secret |
| 70 | + OPENTAXII_DOMAIN: localhost:9000 |
| 71 | + OPENTAXII_USER: user1 |
| 72 | + OPENTAXII_PASS: pass1 |
| 73 | + DB_HOST: db |
| 74 | + DB_PORT: 3306 |
| 75 | + DB_NAME: opentaxii |
| 76 | + DB_USER: user |
| 77 | + DB_PASS: password |
| 78 | + ports: |
| 79 | + - 9000:9000 |
| 80 | + links: |
| 81 | + - db:db |
| 82 | +
|
| 83 | +This configuration starts two containers: 'opentaxii' and 'mysql', creates the given collections and services, and adds a user for authentication. |
| 84 | + |
| 85 | + |
| 86 | +.. rubric:: Next steps |
| 87 | + |
| 88 | +Continue to :doc:`Authentication <auth>` page to learn how OpenTAXII authentication process works. |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +.. vim: set spell spelllang=en: |
0 commit comments