You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
7.3 KiB

  1. # Install doccano
  2. Install doccano on local or in the cloud. Choose the installation method that works best for your environment:
  3. - [Install with pip](#install-with-pip)
  4. - [Install with Docker](#install-with-docker)
  5. - [Install with Docker Compose](#install-with-docker-compose)
  6. - [Install from source](#install-from-source)
  7. - [Install to cloud](#install-to-cloud)
  8. - [Upgrade doccano](#upgrade-doccano)
  9. ## System requirements
  10. You can install doccano on a Linux, Windows, or macOS machine running Python 3.8+.
  11. ### Web browser support
  12. doccano is tested with the latest version of Google Chrome and is expected to work in the latest versions of:
  13. - Google Chrome
  14. - Apple Safari
  15. If using other web browsers, or older versions of supported web browsers, unexpected behavior could occur.
  16. ### Port requirements
  17. doccano uses port 8000 by default. To use a different port, specify it when running doccano webserver.
  18. ## Install with pip
  19. To install doccano with pip, you need Python 3.8+. Run the following:
  20. ```bash
  21. pip install doccano
  22. ```
  23. After you install doccano, start the server with the following command:
  24. ```bash
  25. # Initialize database. First time only.
  26. doccano init
  27. # Create a super user. First time only.
  28. doccano createuser --username admin --password pass
  29. # Start a web server.
  30. doccano webserver --port 8000
  31. ```
  32. In another terminal, run the following command:
  33. ```bash
  34. # Start the task queue to handle file upload/download.
  35. doccano task
  36. ```
  37. Open <http://localhost:8000/>.
  38. ## Install with Docker
  39. doccano is also available as a [Docker](https://www.docker.com/) container. Make sure you have Docker installed on your machine.
  40. To install and start doccano at <http://localhost:8000>, run the following command:
  41. ```bash
  42. docker pull doccano/doccano
  43. docker container create --name doccano \
  44. -e "ADMIN_USERNAME=admin" \
  45. -e "ADMIN_EMAIL=admin@example.com" \
  46. -e "ADMIN_PASSWORD=password" \
  47. -v doccano-db:/data \
  48. -p 8000:8000 doccano/doccano
  49. ```
  50. Next, start doccano by running the container:
  51. ```bash
  52. docker container start doccano
  53. ```
  54. To stop the container, run `docker container stop doccano -t 5`.
  55. All data created in the container persist across restarts.
  56. ### Build a local image with Docker
  57. If you want to build a local image, run:
  58. ```bash
  59. docker build -t doccano:latest . -f docker/Dockerfile
  60. ```
  61. ## Install with Docker Compose
  62. You need to install Git and to clone the repository:
  63. ```bash
  64. git clone https://github.com/doccano/doccano.git
  65. cd doccano
  66. ```
  67. To install and start doccano at <http://localhost>, run the following command:
  68. ```bash
  69. docker-compose -f docker/docker-compose.prod.yml --env-file .env up
  70. ```
  71. You can override the default setting by rewriting the `.env` file. See [./docker/.env.example](https://github.com/doccano/doccano/blob/master/docker/.env.example) in detail.
  72. ## Install from source
  73. If you want to develop doccano, consider downloading the source code using Git and running doccano locally. First of all, clone the repository:
  74. ```bash
  75. git clone https://github.com/doccano/doccano.git
  76. cd doccano
  77. ```
  78. ### Backend
  79. The doccano backend is built in Python 3.8+ and uses [Poetry](https://github.com/python-poetry/poetry) as a dependency manager. If you haven't installed them yet, please see [Python](https://www.python.org/downloads/) and [Poetry](https://python-poetry.org/docs/) documentation.
  80. First, to install the defined dependencies for our project, just run the `install` command. After that, activate the virtual environment by running `shell` command:
  81. ```bash
  82. cd backend
  83. poetry install
  84. poetry shell
  85. ```
  86. Second, set up the database and run the development server. Doccano uses [Django](https://www.djangoproject.com/) and [Django Rest Framework](https://www.django-rest-framework.org/) as a backend. We can set up them by using Django command:
  87. ```bash
  88. python manage.py migrate
  89. python manage.py create_roles
  90. python manage.py create_admin --noinput --username "admin" --email "admin@example.com" --password "password"
  91. python manage.py runserver
  92. ```
  93. In another terminal, you need to run Celery to use import/export dataset feature:
  94. ```bash
  95. cd doccano/backend
  96. celery --app=config worker --loglevel=INFO --concurrency=1
  97. ```
  98. After you change the code, don't forget to run [mypy](https://mypy.readthedocs.io/en/stable/index.html), [flake8](https://flake8.pycqa.org/en/latest/), [black](https://github.com/psf/black), and [isort](https://github.com/PyCQA/isort). These ensure code consistency. To run them, just run the following commands:
  99. ```bash
  100. poetry run task mypy
  101. poetry run task flake8
  102. poetry run task black
  103. poetry run task isort
  104. ```
  105. Similarly, you can run the test by executing the following command:
  106. ```bash
  107. poetry run task test
  108. ```
  109. Did you pass the test? Great!
  110. ### Frontend
  111. The doccano frontend is built in Node.js and uses [Yarn](https://yarnpkg.com/) as a package manager. If you haven't installed them yet, please see [Node.js](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/) documentation.
  112. First, to install the defined dependencies for our project, just run the `install` command.
  113. ```bash
  114. cd frontend
  115. yarn install
  116. ```
  117. Then run the `dev` command to serve with hot reload at <localhost:3000>:
  118. ```bash
  119. yarn dev
  120. ```
  121. ### How to create a Python package
  122. During development, you may want to create a Python package and verify it works correctly. In such a case, you can create a package by running the following command in the root directory of your project:
  123. ```bash
  124. ./tools/create-package.sh
  125. ```
  126. This command builds the frontend, copies the files, and packages them. This will take a few minutes. After finishing the command, you will find `sdist` and `wheel` in `backend/dist`:
  127. ```bash
  128. Building doccano (1.5.5.post335.dev0+6be6d198)
  129. - Building sdist
  130. - Built doccano-1.5.5.post335.dev0+6be6d198.tar.gz
  131. - Building wheel
  132. - Built doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl
  133. ```
  134. Then, you can install the package via `pip install` command:
  135. ```bash
  136. pip install doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl
  137. ```
  138. ## Install to cloud
  139. doccano also supports one-click deployment to cloud providers. Click the following button, configure the environment, and access the UI.
  140. | Service | Button |
  141. |---------|---|
  142. | AWS | [![AWS CloudFormation Launch Stack SVG Button](https://cdn.rawgit.com/buildkite/cloudformation-launch-stack-button-svg/master/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=doccano&templateURL=https://doccano.s3.amazonaws.com/public/cloudformation/template.aws.yaml) |
  143. | Heroku | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fdoccano%2Fdoccano) |
  144. ## Upgrade doccano
  145. Caution: If you use SQLite3 as a database, upgrading the package would lose your database.
  146. The migrate command has been supported since v1.6.0.
  147. ### After v1.6.0
  148. To upgrade to the latest version of doccano, reinstall or upgrade using pip.
  149. ```bash
  150. pip install -U doccano
  151. ```
  152. If you need to update the database scheme, run the following:
  153. ```bash
  154. doccano migrate
  155. ```
  156. ### Before v1.6.0
  157. First, you need to copy the database file and media directory in the case of SQLite3:
  158. ```bash
  159. mkdir -p ~/doccano
  160. # Replace your path.
  161. cp venv/lib/python3.8/site-packages/backend/db.sqlite3 ~/doccano/
  162. cp -r venv/lib/python3.8/site-packages/backend/media ~/doccano/
  163. ```
  164. Then, upgrade the package:
  165. ```bash
  166. pip install -U doccano
  167. ```
  168. At the end, run the migration:
  169. ```bash
  170. doccano migrate
  171. ```