-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cvat-ui in docker (serve using nginx) (#658)
- Loading branch information
Showing
17 changed files
with
191 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
/.vscode | ||
/db.sqlite3 | ||
/keys | ||
package-lock.json | ||
node_modules | ||
**/node_modules | ||
cvat-ui | ||
cvat-canvas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
REACT_APP_VERSION=${npm_package_version} | ||
|
||
REACT_APP_API_PROTOCOL=http | ||
REACT_APP_API_HOST=localhost | ||
REACT_APP_API_PORT=8080 | ||
REACT_APP_API_HOST_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT} | ||
REACT_APP_API_FULL_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT}/api/v1 | ||
|
||
SKIP_PREFLIGHT_CHECK=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM ubuntu:18.04 AS cvat-ui | ||
|
||
ARG http_proxy | ||
ARG https_proxy | ||
ARG no_proxy | ||
ARG socks_proxy | ||
|
||
ENV TERM=xterm \ | ||
http_proxy=${http_proxy} \ | ||
https_proxy=${https_proxy} \ | ||
no_proxy=${no_proxy} \ | ||
socks_proxy=${socks_proxy} | ||
|
||
ENV LANG='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 directory | ||
RUN mkdir /tmp/cvat-ui | ||
WORKDIR /tmp/cvat-ui/ | ||
|
||
# Install dependencies | ||
COPY package*.json /tmp/cvat-ui/ | ||
RUN npm install | ||
|
||
# Build source code | ||
COPY . /tmp/cvat-ui/ | ||
RUN mv .env.production .env && npm run build | ||
|
||
FROM nginx | ||
# Replace default.conf configuration to remove unnecessary rules | ||
COPY react_nginx.conf /etc/nginx/conf.d/default.conf | ||
COPY --from=cvat-ui /tmp/cvat-ui/build /usr/share/nginx/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
server { | ||
root /usr/share/nginx/html; | ||
# Any route that doesn't have a file extension (e.g. /devices) | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.core import signing | ||
from furl import furl | ||
import hashlib | ||
|
||
QUERY_PARAM = 'sign' | ||
MAX_AGE = 30 | ||
|
||
# Got implementation ideas in https://github.com/marcgibbons/drf_signed_auth | ||
class Signer: | ||
@classmethod | ||
def get_salt(cls, url): | ||
normalized_url = furl(url).remove(QUERY_PARAM).url.encode('utf-8') | ||
salt = hashlib.sha256(normalized_url).hexdigest() | ||
return salt | ||
|
||
def sign(self, user, url): | ||
""" | ||
Create a signature for a user object. | ||
""" | ||
data = { | ||
'user_id': user.pk, | ||
'username': user.get_username() | ||
} | ||
|
||
return signing.dumps(data, salt=self.get_salt(url)) | ||
|
||
def unsign(self, signature, url): | ||
""" | ||
Return a user object for a valid signature. | ||
""" | ||
User = get_user_model() | ||
data = signing.loads(signature, salt=self.get_salt(url), max_age=MAX_AGE) | ||
|
||
if not isinstance(data, dict): | ||
raise signing.BadSignature() | ||
|
||
try: | ||
return User.objects.get(**{ | ||
'pk': data.get('user_id'), | ||
User.USERNAME_FIELD: data.get('username') | ||
}) | ||
except User.DoesNotExist: | ||
raise signing.BadSignature() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters