|
1 | 1 | Setup and configuration
|
2 | 2 | =======================
|
3 | 3 |
|
4 |
| -Prerequisites |
5 |
| -------------- |
| 4 | +Installation and configuration with Docker Compose |
| 5 | +-------------------------------------------------- |
| 6 | + |
| 7 | +The quickest way setup MWDB is to just clone the repository and use Docker-Compose with all batteries included. |
| 8 | + |
| 9 | +.. code-block:: console |
| 10 | +
|
| 11 | + $ git clone https://github.com/CERT-Polska/mwdb-core.git |
| 12 | +
|
| 13 | +After cloning repository, the first step is to go to the ``mwdb-core`` directory and generate configuration using ``./gen_vars.sh`` script. |
| 14 | +Generated variables can be found in mwdb-vars.env. |
| 15 | + |
| 16 | +.. code-block:: console |
| 17 | +
|
| 18 | + $ ./gen_vars.sh |
| 19 | + Credentials for initial mwdb account: |
| 20 | +
|
| 21 | + ----------------------------------------- |
| 22 | + Admin login: admin |
| 23 | + Admin password: la/Z7MsmKA3UxW8Psrk1Opap |
| 24 | + ----------------------------------------- |
| 25 | +
|
| 26 | + Please be aware that initial account will be only set up on the first run. If you already have a database with at least one user, then this setting will be ignored for security reasons. You can always create an admin account manually by executing a command. See "flask create_admin --help" for reference. |
| 27 | +
|
| 28 | +Then build images via ``docker-compose build`` and run MWDB via ``docker-compose up -d``. |
| 29 | + |
| 30 | +Your MWDB instance will be available on default HTTP port (80): http://127.0.0.1/ |
| 31 | + |
| 32 | +If you want to use Docker Compose for MWDB development, check out :ref:`Developer guide`. |
| 33 | + |
| 34 | +Standalone installation |
| 35 | +----------------------- |
| 36 | + |
| 37 | +Step 1.: Prerequisites |
| 38 | +~~~~~~~~~~~~~~~~~~~~~~ |
6 | 39 |
|
7 | 40 | MWDB was tested on Debian-based systems, but should work as well on other Linux distributions.
|
8 | 41 |
|
9 | 42 | For production environments, you need to install:
|
10 | 43 |
|
11 | 44 |
|
12 | 45 | * **PostgreSQL database** (minimum supported version: 12, https://www.postgresql.org/download/linux/debian/)
|
13 |
| -* **python-ssdeep library dependencies for Python 3** (https://python-ssdeep.readthedocs.io/en/latest/installation.html#id9) |
14 | 46 |
|
15 | 47 | Optionally you can install:
|
16 | 48 |
|
@@ -41,8 +73,8 @@ It's highly recommended to create a fresh `virtualenv <https://docs.python.org/3
|
41 | 73 |
|
42 | 74 | The connection string is: ``postgresql://mwdb:mwdb@127.0.0.1:54322/mwdb``
|
43 | 75 |
|
44 |
| -Installation & Configuration |
45 |
| ----------------------------- |
| 76 | +Step 2.: Installation and configuration |
| 77 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
46 | 78 |
|
47 | 79 | The recommended installation method is pip:
|
48 | 80 |
|
@@ -87,14 +119,14 @@ Then, use ``mwdb-core configure`` to provide first configuration for your MWDB s
|
87 | 119 | 3) Current directory
|
88 | 120 | : 3
|
89 | 121 |
|
90 |
| -For first installation we recommend to install everything in current folder via ``3`` option. If you want to install MWDB system-wide or locally for user: choose ``1`` or ``2``. |
| 122 | +For first installation we recommend to install everything in current folder via ``3`` option. If you want to install MWDB system-wide or locally for user: choose ``1`` or ``2``. |
91 | 123 |
|
92 | 124 | Then, input the connection string for PostgreSQL database. The database must be online and reachable at the time of configuration. After that, you will be asked for path for uploads and instance base URL. If the default value is ok, press Enter:
|
93 | 125 |
|
94 | 126 | .. code-block::
|
95 | 127 |
|
96 | 128 | PostgreSQL database connection string [postgresql://localhost/mwdb]:
|
97 |
| - Uploads storage path [./uploads]: |
| 129 | + Uploads storage path [./uploads]: |
98 | 130 | Base public URL of Malwarecage service [http://127.0.0.1]:
|
99 | 131 |
|
100 | 132 | Depending on the installation type, your configuration will be stored in ``mwdb.ini`` file and can be changed any time you want:
|
@@ -136,42 +168,30 @@ And you are done! ``run`` command will start the Flask server:
|
136 | 168 |
|
137 | 169 | Your MWDB instance will be available on port 5000 (use ``--port`` to change that): http://127.0.0.1:5000/
|
138 | 170 |
|
139 |
| -.. warning:: |
140 |
| - |
141 |
| - Remember to run ``mwdb-core configure`` after each version upgrade to apply database migrations |
142 |
| - |
143 |
| - |
144 |
| -Alternative setup with Docker Compose |
145 |
| --------------------------------------- |
| 171 | +Keep in mind that Flask server is meant to be used as development server and **is not suitable for production**. |
| 172 | +See also: https://flask.palletsprojects.com/en/2.2.x/server/ |
146 | 173 |
|
147 |
| -The quickest way setup MWDB is to just clone the repository and use Docker-Compose. We recommend this method **only for testing** because it can be a bit more difficult to install extensions and integrate with other services. |
148 |
| - |
149 |
| -.. code-block:: console |
150 |
| -
|
151 |
| - $ git clone https://github.com/CERT-Polska/mwdb-core.git |
152 |
| -
|
153 |
| -After cloning repository, the first step is to go to the ``mwdb-core`` directory and generate configuration using ``./gen_vars.sh`` script. |
| 174 | +.. warning:: |
154 | 175 |
|
155 |
| -.. code-block:: console |
| 176 | + In standalone setup, remember to run ``mwdb-core configure`` after each version upgrade to apply database migrations. |
156 | 177 |
|
157 |
| - $ ./gen_vars.sh |
158 |
| - Credentials for initial mwdb account: |
| 178 | +Step 3.: Setting up gunicorn and nginx |
| 179 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
159 | 180 |
|
160 |
| - ----------------------------------------- |
161 |
| - Admin login: admin |
162 |
| - Admin password: la/Z7MsmKA3UxW8Psrk1Opap |
163 |
| - ----------------------------------------- |
| 181 | +It's recommended to deploy Flask applications using dedicated WSGI server. We highly recommend Gunicorn as it's used |
| 182 | +in our Docker images and combine it with Nginx serving as proxy server for best security and performance |
164 | 183 |
|
165 |
| - Please be aware that initial account will be only set up on the first run. If you already have a database with at least one user, then this setting will be ignored for security reasons. You can always create an admin account manually by executing a command. See "flask create_admin --help" for reference. |
| 184 | +.. seealso:: |
166 | 185 |
|
167 |
| -Then build images via ``docker-compose build`` and run MWDB via ``docker-compose up -d``. |
| 186 | + https://flask.palletsprojects.com/en/2.2.x/deploying/gunicorn/ |
168 | 187 |
|
169 |
| -Your MWDB instance will be available on default HTTP port (80): http://127.0.0.1/ |
| 188 | + https://docs.gunicorn.org/en/latest/deploy.html#deploying-gunicorn |
170 | 189 |
|
171 |
| -If you want to use Docker Compose for MWDB development, check out :ref:`Developer guide`. |
| 190 | +Proper configuration files and templates used in our Docker images can be found in `docker directory on our Github repository |
| 191 | +<https://github.com/CERT-Polska/mwdb-core/tree/master/docker>`_ |
172 | 192 |
|
173 |
| -Upgrade mwdb-core to latest version |
174 |
| ------------------------------------ |
| 193 | +Upgrading mwdb-core to latest version |
| 194 | +------------------------------------- |
175 | 195 |
|
176 | 196 | For standalone installation (pip-based), upgrade mwdb-core package to the latest version.
|
177 | 197 |
|
|
0 commit comments