Az/cvat proxy (#1177)

* added nginx proxy

* removed unnecessary port configuration & build arg

* updated installation guide
main
Andrey Zhavoronkov 6 years ago committed by GitHub
parent adb66b57ba
commit 0dae5def6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,12 +1,9 @@
FROM ubuntu:18.04 AS cvat-ui FROM node:lts-alpine AS cvat-ui
ARG http_proxy ARG http_proxy
ARG https_proxy ARG https_proxy
ARG no_proxy ARG no_proxy
ARG socks_proxy ARG socks_proxy
ARG REACT_APP_API_PORT
ARG REACT_APP_API_PROTOCOL
ARG REACT_APP_API_HOST
ENV TERM=xterm \ ENV TERM=xterm \
http_proxy=${http_proxy} \ http_proxy=${http_proxy} \
@ -17,13 +14,6 @@ ENV TERM=xterm \
ENV LANG='C.UTF-8' \ ENV LANG='C.UTF-8' \
LC_ALL='C.UTF-8' LC_ALL='C.UTF-8'
# Install necessary apt packages
RUN apt update && apt install -yq nodejs npm curl && \
npm install -g n && n 10.16.3
# Create output directories
RUN mkdir /tmp/cvat-ui /tmp/cvat-core /tmp/cvat-canvas
# Install dependencies # Install dependencies
COPY cvat-core/package*.json /tmp/cvat-core/ COPY cvat-core/package*.json /tmp/cvat-core/
COPY cvat-canvas/package*.json /tmp/cvat-canvas/ COPY cvat-canvas/package*.json /tmp/cvat-canvas/
@ -47,7 +37,7 @@ COPY cvat-canvas/ /tmp/cvat-canvas/
COPY cvat-ui/ /tmp/cvat-ui/ COPY cvat-ui/ /tmp/cvat-ui/
RUN npm run build RUN npm run build
FROM nginx FROM nginx:stable-alpine
# Replace default.conf configuration to remove unnecessary rules # Replace default.conf configuration to remove unnecessary rules
COPY cvat-ui/react_nginx.conf /etc/nginx/conf.d/default.conf COPY cvat-ui/react_nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=cvat-ui /tmp/cvat-ui/dist /usr/share/nginx/html/ COPY --from=cvat-ui /tmp/cvat-ui/dist /usr/share/nginx/html/

@ -5,7 +5,7 @@
"main": "src/index.tsx", "main": "src/index.tsx",
"scripts": { "scripts": {
"build": "webpack --config ./webpack.config.js", "build": "webpack --config ./webpack.config.js",
"start": "webpack-dev-server --config ./webpack.config.js --mode=development", "start": "REACT_APP_API_URL=http://localhost:7000 webpack-dev-server --config ./webpack.config.js --mode=development",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch", "type-check:watch": "npm run type-check -- --watch",
"lint": "eslint './src/**/*.{ts,tsx}'", "lint": "eslint './src/**/*.{ts,tsx}'",

@ -6,14 +6,8 @@ import _cvat from '../../cvat-core/src/api';
const cvat: any = _cvat; const cvat: any = _cvat;
const protocol = typeof (process.env.REACT_APP_API_PROTOCOL) === 'undefined' cvat.config.backendAPI = typeof (process.env.REACT_APP_API_URL) === 'undefined'
? 'http' : process.env.REACT_APP_API_PROTOCOL; ? '/api/v1' : `${process.env.REACT_APP_API_URL}/api/v1`;
const host = typeof (process.env.REACT_APP_API_HOST) === 'undefined'
? 'localhost' : process.env.REACT_APP_API_HOST;
const port = typeof (process.env.REACT_APP_API_PORT) === 'undefined'
? '7000' : process.env.REACT_APP_API_PORT;
cvat.config.backendAPI = `${protocol}://${host}:${port}/api/v1`;
export default function getCore(): any { export default function getCore(): any {
return cvat; return cvat;

@ -262,9 +262,8 @@ docker-compose down
### Advanced settings ### Advanced settings
If you want to access you instance of CVAT outside of your localhost you should If you want to access your instance of CVAT outside of your localhost you should
specify the [ALLOWED_HOSTS](https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts) specify the `CVAT_HOST` environment variable. The best way to do that is to create
environment variable. The best way to do that is to create
[docker-compose.override.yml](https://docs.docker.com/compose/extends/) and put [docker-compose.override.yml](https://docs.docker.com/compose/extends/) and put
all your extra settings here. all your extra settings here.
@ -272,11 +271,9 @@ all your extra settings here.
version: "2.3" version: "2.3"
services: services:
cvat: cvat_proxy:
environment: environment:
ALLOWED_HOSTS: .example.com CVAT_HOST: .example.com
ports:
- "80:8080"
``` ```
Please don't forget include this file to docker-compose commands using the `-f` Please don't forget include this file to docker-compose commands using the `-f`

@ -0,0 +1,37 @@
server {
listen 80;
server_name _ default;
return 404;
}
server {
listen 80;
server_name ${CVAT_HOST};
location ~* /api/.*|git/.*|tensorflow/.*|auto_annotation/.*|analytics/.*|static/.*|admin|admin/.*|documentation/.*|dextr/.*|reid/.* {
proxy_pass http://cvat:8080;
proxy_pass_header X-CSRFToken;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
}
location / {
# workaround for match location by arguments
error_page 418 = @annotation_ui;
if ( $query_string ~ "^id=\d+.*" ) { return 418; }
proxy_pass http://cvat_ui;
proxy_pass_header X-CSRFToken;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
}
# old annotation ui, will be removed in the future.
location @annotation_ui {
proxy_pass http://cvat:8080;
proxy_pass_header X-CSRFToken;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
}
}

@ -0,0 +1,16 @@
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
client_max_body_size 0;
}

@ -1,5 +1,5 @@
# #
# Copyright (C) 2018 Intel Corporation # Copyright (C) 2018-2020 Intel Corporation
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# #
@ -37,8 +37,6 @@ services:
depends_on: depends_on:
- cvat_redis - cvat_redis
- cvat_db - cvat_db
ports:
- "8080:8080"
build: build:
context: . context: .
args: args:
@ -54,11 +52,7 @@ services:
OPENVINO_TOOLKIT: "no" OPENVINO_TOOLKIT: "no"
environment: environment:
DJANGO_MODWSGI_EXTRA_ARGS: "" DJANGO_MODWSGI_EXTRA_ARGS: ""
UI_SCHEME: http ALLOWED_HOSTS: '*'
UI_HOST: localhost
UI_PORT: 7080
volumes: volumes:
- cvat_data:/home/django/data - cvat_data:/home/django/data
- cvat_keys:/home/django/keys - cvat_keys:/home/django/keys
@ -67,7 +61,6 @@ services:
cvat_ui: cvat_ui:
container_name: cvat_ui container_name: cvat_ui
image: nginx
restart: always restart: always
build: build:
context: . context: .
@ -76,9 +69,6 @@ services:
https_proxy: https_proxy:
no_proxy: no_proxy:
socks_proxy: socks_proxy:
REACT_APP_API_PROTOCOL: http
REACT_APP_API_HOST: localhost
REACT_APP_API_PORT: 8080
dockerfile: Dockerfile.ui dockerfile: Dockerfile.ui
networks: networks:
@ -87,8 +77,22 @@ services:
- ui - ui
depends_on: depends_on:
- cvat - cvat
cvat_proxy:
container_name: cvat_proxy
image: nginx:stable-alpine
restart: always
depends_on:
- cvat
- cvat_ui
environment:
CVAT_HOST: localhost
ports: ports:
- "7080:80" - "8080:80"
volumes:
- ./cvat_proxy/nginx.conf:/etc/nginx/nginx.conf:ro
- ./cvat_proxy/conf.d/cvat.conf.template:/etc/nginx/conf.d/cvat.conf.template:ro
command: /bin/sh -c "envsubst '$$CVAT_HOST' < /etc/nginx/conf.d/cvat.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
volumes: volumes:
cvat_db: cvat_db:

Loading…
Cancel
Save