diff --git a/README.md b/README.md
index f1859af1..924d07c8 100644
--- a/README.md
+++ b/README.md
@@ -82,6 +82,16 @@ All data created in the container will persist across restarts.
Access .
+### For Developers
+
+```bash
+$ git clone https://github.com/doccano/doccano.git
+$ cd doccano
+$ docker-compose -f docker-compose.dev.yml up
+```
+
+Access .
+
## One-click Deployment
| Service | Button |
diff --git a/app/app/settings.py b/app/app/settings.py
index 195c65e9..52d1e1d0 100644
--- a/app/app/settings.py
+++ b/app/app/settings.py
@@ -60,6 +60,7 @@ INSTALLED_APPS = [
'social_django',
'polymorphic',
'webpack_loader',
+ 'corsheaders',
]
CLOUD_BROWSER_APACHE_LIBCLOUD_PROVIDER = env('CLOUD_BROWSER_LIBCLOUD_PROVIDER', None)
@@ -82,6 +83,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'applicationinsights.django.ApplicationInsightsMiddleware',
+ 'corsheaders.middleware.CorsMiddleware',
]
ROOT_URLCONF = 'app.urls'
@@ -305,3 +307,10 @@ EMAIL_PORT = env.int('EMAIL_PORT', 587)
if not EMAIL_HOST:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+
+if DEBUG:
+ CORS_ORIGIN_WHITELIST = (
+ 'http://127.0.0.1:3000',
+ 'http://0.0.0.0:3000',
+ )
diff --git a/app/requirements.txt b/app/requirements.txt
index 0ce100cb..bca1d95b 100644
--- a/app/requirements.txt
+++ b/app/requirements.txt
@@ -6,6 +6,7 @@ coverage==4.5.3
dj-database-url==0.5.0
Django==2.1.11
django-cloud-browser==0.5.0
+django-cors-headers==3.1.1
django-filter==2.0.0
django-heroku==0.3.1
django-webpack-loader==0.6.0
diff --git a/app/tools/dev-django.sh b/app/tools/dev-django.sh
new file mode 100755
index 00000000..384795c2
--- /dev/null
+++ b/app/tools/dev-django.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+set -o errexit
+
+root="$(dirname "$0")/../.."
+app="${root}/app"
+venv="${root}/venv"
+
+if [[ ! -f "${venv}/bin/python" ]]; then
+ echo "Creating virtualenv"
+ mkdir -p "${venv}"
+ python3 -m venv "${venv}"
+ "${venv}/bin/pip" install --upgrade pip setuptools
+fi
+
+echo "Installing dependencies"
+apt-get update && apt-get install -y g++ unixodbc-dev # pyodbc build dependencies
+"${venv}/bin/pip" install -r "${app}/requirements.txt"
+
+echo "Initializing database"
+"${venv}/bin/python" "${app}/manage.py" wait_for_db
+"${venv}/bin/python" "${app}/manage.py" migrate
+"${venv}/bin/python" "${app}/manage.py" create_roles
+
+if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
+ "${venv}/bin/python" "${app}/manage.py" create_admin \
+ --username "${ADMIN_USERNAME}" \
+ --password "${ADMIN_PASSWORD}" \
+ --email "${ADMIN_EMAIL}" \
+ --noinput \
+ || true
+fi
+
+echo "Starting django"
+"${venv}/bin/python" -u "${app}/manage.py" runserver "$@"
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
new file mode 100644
index 00000000..b25eb97c
--- /dev/null
+++ b/docker-compose.dev.yml
@@ -0,0 +1,55 @@
+version: "3.7"
+services:
+
+ backend:
+ image: python:3.6
+ volumes:
+ - .:/src
+ - venv:/src/venv
+ command: ["/src/app/tools/dev-django.sh", "0.0.0.0:8000"]
+ environment:
+ ADMIN_USERNAME: "admin"
+ ADMIN_PASSWORD: "password"
+ ADMIN_EMAIL: "admin@example.com"
+ DATABASE_URL: "postgres://doccano:doccano@postgres:5432/doccano?sslmode=disable"
+ ALLOW_SIGNUP: "False"
+ ports:
+ - 8000:8000
+ depends_on:
+ - postgres
+ networks:
+ - network-backend
+ - network-frontend
+
+ frontend:
+ image: node:13.2.0
+ command: ["/src/frontend/dev-nuxt.sh"]
+ volumes:
+ - .:/src
+ - node_modules:/src/frontend/node_modules
+ ports:
+ - 3000:3000
+ depends_on:
+ - backend
+ networks:
+ - network-frontend
+
+ postgres:
+ image: postgres:12.0-alpine
+ volumes:
+ - postgres_data:/var/lib/postgresql/data/
+ environment:
+ POSTGRES_USER: "doccano"
+ POSTGRES_PASSWORD: "doccano"
+ POSTGRES_DB: "doccano"
+ networks:
+ - network-backend
+
+volumes:
+ postgres_data:
+ node_modules:
+ venv:
+
+networks:
+ network-backend:
+ network-frontend:
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
index 8bf771e6..e1a76abd 100644
--- a/frontend/.eslintrc.js
+++ b/frontend/.eslintrc.js
@@ -15,11 +15,12 @@ module.exports = {
rules: {
"no-console": "off",
"no-restricted-syntax": [
- "error",
- {
- "selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",
- "message": "Unexpected property on console object was called"
- }
- ]
+ "error",
+ {
+ "selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",
+ "message": "Unexpected property on console object was called"
+ }
+ ],
+ "vue/valid-template-root": "off"
}
}
diff --git a/frontend/dev-nuxt.sh b/frontend/dev-nuxt.sh
new file mode 100755
index 00000000..fd5744a5
--- /dev/null
+++ b/frontend/dev-nuxt.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+set -o errexit
+
+root="$(dirname "$0")/.."
+app="${root}/frontend"
+
+(
+ cd "${app}"
+
+ if [[ ! -d node_modules/.bin ]]; then
+ echo "Installing dependencies"
+ npm install
+ fi
+
+ echo "Starting frontend server"
+ npm run lintfix
+ npm run dev
+)
diff --git a/frontend/nuxt.config.js b/frontend/nuxt.config.js
index 782ec3e6..d3ccb678 100644
--- a/frontend/nuxt.config.js
+++ b/frontend/nuxt.config.js
@@ -30,6 +30,10 @@ export default {
'~/api/index.js'
],
+ server: {
+ host: '0.0.0.0' // default: localhost
+ },
+
env: {
baseUrl: process.env.NODE_ENV === 'production' ? '/v1' : 'http://127.0.0.1:8000/v1'
},