1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/librephotos_ynh.git synced 2024-09-03 19:36:12 +02:00

Improvements

This commit is contained in:
yalh76 2022-07-28 01:46:19 +02:00
parent 31de75b5ed
commit c56ccd9c6b
3 changed files with 34 additions and 38 deletions

View file

@ -17,27 +17,27 @@ location ~ ^/(api|media)/ {
} }
# Django media # Django media
location /protected_media { location /protected_media/ {
internal; internal;
alias /home/yunohost.app/__NAME__/protected_media/; alias /home/yunohost.app/__NAME__/protected_media/;
} }
location /static/drf-yasg { location /static/drf-yasg/ {
proxy_pass http://127.0.0.1:__BACKEND_PORT__; proxy_pass http://127.0.0.1:__BACKEND_PORT__;
} }
location /data { location /data/ {
internal; internal;
alias /home/yunohost.app/__NAME__/data/; alias /home/yunohost.app/__NAME__/data/;
} }
# Original Photos # Original Photos
location /original { location /original/ {
internal; internal;
alias /home/yunohost.app/__NAME__/data/; alias /home/yunohost.app/__NAME__/data/;
} }
# Nextcloud Original Photos # Nextcloud Original Photos
location /nextcloud_original { location /nextcloud_original/ {
internal; internal;
alias /home/yunohost.app/__NAME__/data/nextcloud_media/; alias /home/yunohost.app/__NAME__/data/nextcloud_media/;
} }

View file

@ -43,7 +43,7 @@ function unpack_source {
ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR" ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR"
ynh_setup_source --source_id="cmake" --dest_dir="$final_path/backend/cmake/" ynh_setup_source --source_id="cmake" --dest_dir="$final_path/backend/cmake/"
else else
wget -O "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh wget -O "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh 2>&1
ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/" ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/"
fi fi
#ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/" #ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/"
@ -56,6 +56,7 @@ function set_up_backend {
backend_path="$final_path/backend" backend_path="$final_path/backend"
pushd "$backend_path" pushd "$backend_path"
chown -R $app:$app "$backend_path" chown -R $app:$app "$backend_path"
chown -R $app:$app $data_path
ynh_exec_warn_less ynh_exec_as $app python3 -m venv $backend_path/venv ynh_exec_warn_less ynh_exec_as $app python3 -m venv $backend_path/venv
path_prefix="$backend_path/venv/bin" path_prefix="$backend_path/venv/bin"
if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
@ -85,15 +86,14 @@ function set_up_backend {
else else
ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
fi fi
pushd "$backend_path/dlib" install_dlib
ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" python setup.py install
popd
ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements.txt" ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements.txt"
ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements-ynh.txt" ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements-ynh.txt"
#if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then #if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
#ynh_exec_warn_less ynh_exec_as $app unzip "$CONDA_DIR/lib/python3.8/site-packages/"faiss*.egg -d "$CONDA_DIR/lib/python3.8/site-packages/" #ynh_exec_warn_less ynh_exec_as $app unzip "$CONDA_DIR/lib/python3.8/site-packages/"faiss*.egg -d "$CONDA_DIR/lib/python3.8/site-packages/"
#fi #fi
chown -R root:root "$backend_path" chown -R root:root "$backend_path"
chown -R root:root $data_path
popd popd
} }
@ -115,11 +115,12 @@ function set_up_frontend {
frontend_path=$final_path/frontend frontend_path=$final_path/frontend
pushd $final_path/frontend pushd $final_path/frontend
chown -R $app:$app $frontend_path chown -R $app:$app $frontend_path
ynh_exec_warn_less ynh_exec_as $app touch $frontend_path/.yarnrc chown -R $app:$app $data_path
ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install --legacy-peer-deps export NODE_OPTIONS="--max-old-space-size=8192"
ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc run build ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --legacy-peer-deps
ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc add serve ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
chown -R root:root $frontend_path chown -R root:root $frontend_path
chown -R root:root $data_path
popd popd
} }

View file

@ -2,60 +2,55 @@ diff --git a/ownphotos/settings.py b/ownphotos/settings.py
index 3449af1..f1a6be7 100644 index 3449af1..f1a6be7 100644
--- a/ownphotos/settings.py --- a/ownphotos/settings.py
+++ b/ownphotos/settings.py +++ b/ownphotos/settings.py
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ @@ -11,6 +11,7 @@
""" """
import datetime import datetime
import os import os
+import ldap, tzlocal +import ldap, tzlocal
for envvar in ( for envvar in (
'SECRET_KEY', "SECRET_KEY",
@@ -76,7 +77,7 @@ CONSTANCE_CONFIG = { @@ -77,7 +78,7 @@
'IMAGE_DIRS': ("/data", 'Image dirs list (serialized json)', str) "IMAGE_DIRS": ("/data", "Image dirs list (serialized json)", str),
} }
-INTERNAL_IPS = ('127.0.0.1', 'localhost', '192.168.1.100') -INTERNAL_IPS = ("127.0.0.1", "localhost", "192.168.1.100")
+INTERNAL_IPS = ('127.0.0.1', 'localhost') +INTERNAL_IPS = ("127.0.0.1", "localhost")
CORS_ALLOW_HEADERS = ( CORS_ALLOW_HEADERS = (
'cache-control', "cache-control",
@@ -93,10 +94,11 @@ CORS_ALLOW_HEADERS = ( @@ -94,7 +95,9 @@
'x-requested-with', "x-requested-with",
) )
-CORS_ORIGIN_WHITELIST = ( -CORS_ORIGIN_WHITELIST = ("http://localhost:3000", "http://192.168.1.100:3000")
- 'http://localhost:3000',
- 'http://192.168.1.100:3000'
-)
+BACKEND_PORT=os.environ['httpPort'] +BACKEND_PORT=os.environ['httpPort']
+ +
+CORS_ORIGIN_WHITELIST = [ +CORS_ORIGIN_WHITELIST = ('http://localhost:' + BACKEND_PORT)
+ 'http://localhost:' + BACKEND_PORT
+]
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ( "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
@@ -231,7 +233,7 @@ AUTH_PASSWORD_VALIDATORS = [ @@ -219,7 +222,7 @@
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = "en-us"
-TIME_ZONE = os.environ['TIME_ZONE'] -TIME_ZONE = os.environ["TIME_ZONE"]
+TIME_ZONE = tzlocal.get_localzone().zone +TIME_ZONE = tzlocal.get_localzone().zone
USE_I18N = True USE_I18N = True
@@ -267,8 +269,8 @@ FULLPHOTO_SIZE = (1000, 1000) @@ -258,8 +261,8 @@
CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_ALLOW_ALL = False
CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_CREDENTIALS = True
-IMAGE_SIMILARITY_SERVER = 'http://localhost:8002' -IMAGE_SIMILARITY_SERVER = "http://localhost:8002"
- -
+IMAGE_SIMILARITY_SERVER_PORT=os.environ['IMAGE_SIMILARITY_SERVER_PORT'] +IMAGE_SIMILARITY_SERVER_PORT=os.environ['IMAGE_SIMILARITY_SERVER_PORT']
+IMAGE_SIMILARITY_SERVER = 'http://localhost:' + IMAGE_SIMILARITY_SERVER_PORT +IMAGE_SIMILARITY_SERVER = 'http://localhost:' + IMAGE_SIMILARITY_SERVER_PORT
#Must be less or egal of nb core CPU ( Nearly 2GB per process) # Must be less or egal of nb core CPU ( Nearly 2GB per process)
HEAVYWEIGHT_PROCESS_ENV = os.environ.get('HEAVYWEIGHT_PROCESS', '1') HEAVYWEIGHT_PROCESS_ENV = os.environ.get("HEAVYWEIGHT_PROCESS", "1")
@@ -289,3 +291,12 @@ LOGGING = { @@ -282,3 +285,12 @@
}, },
}, },
} }