From 9db631208139165c330ef991dff4c645f0fc66c1 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:36:48 +0530 Subject: [PATCH] fix: self hosted instance (#2795) * dev: update create bucket script * dev: update patch endpoint for instance configuration * dev: add google client secret and default values for ADMIN_EMAIL and LICENSE_ENGINE_BASE_URL --- apiserver/bin/takeoff | 2 +- apiserver/plane/license/api/views/instance.py | 23 +++++++++++-------- .../management/commands/configure_instance.py | 1 + deploy/selfhost/docker-compose.yml | 2 ++ deploy/selfhost/variables.env | 6 +++++ 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/apiserver/bin/takeoff b/apiserver/bin/takeoff index 13e557edc..637305457 100755 --- a/apiserver/bin/takeoff +++ b/apiserver/bin/takeoff @@ -15,6 +15,6 @@ if [ "$ENABLE_REGISTRATION" != "0" ]; then fi # Create the default bucket -python bin/bucket_script.py +python manage.py create_bucket exec gunicorn -w $GUNICORN_WORKERS -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:8000 --max-requests 1200 --max-requests-jitter 1000 --access-logfile - diff --git a/apiserver/plane/license/api/views/instance.py b/apiserver/plane/license/api/views/instance.py index 6b27419fd..15c779e46 100644 --- a/apiserver/plane/license/api/views/instance.py +++ b/apiserver/plane/license/api/views/instance.py @@ -230,13 +230,18 @@ class InstanceConfigurationEndpoint(BaseAPIView): return Response(serializer.data, status=status.HTTP_200_OK) def patch(self, request): - key = request.data.get("key", False) - if not key: - return Response( - {"error": "Key is required"}, status=status.HTTP_400_BAD_REQUEST - ) - configuration = InstanceConfiguration.objects.get(key=key) - configuration.value = request.data.get("value") - configuration.save() - serializer = InstanceConfigurationSerializer(configuration) + configurations = InstanceConfiguration.objects.filter(key__in=request.data.keys()) + + bulk_configurations = [] + for configuration in configurations: + configuration.value = request.data.get(configuration.key, configuration.value) + bulk_configurations.append(configuration) + + InstanceConfiguration.objects.bulk_update( + bulk_configurations, + ["value"], + batch_size=100 + ) + + serializer = InstanceConfigurationSerializer(configurations, many=True) return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/apiserver/plane/license/management/commands/configure_instance.py b/apiserver/plane/license/management/commands/configure_instance.py index d71d9f590..9e3e253ad 100644 --- a/apiserver/plane/license/management/commands/configure_instance.py +++ b/apiserver/plane/license/management/commands/configure_instance.py @@ -15,6 +15,7 @@ class Command(BaseCommand): config_keys = { # Authentication Settings "GOOGLE_CLIENT_ID": os.environ.get("GOOGLE_CLIENT_ID"), + "GOOGLE_CLIENT_SECRET": os.environ.get("GOOGLE_CLIENT_SECRET"), "GITHUB_CLIENT_ID": os.environ.get("GITHUB_CLIENT_ID"), "GITHUB_CLIENT_SECRET": os.environ.get("GITHUB_CLIENT_SECRET"), "ENABLE_SIGNUP": os.environ.get("ENABLE_SIGNUP", "1"), diff --git a/deploy/selfhost/docker-compose.yml b/deploy/selfhost/docker-compose.yml index d324605ef..29676d9f8 100644 --- a/deploy/selfhost/docker-compose.yml +++ b/deploy/selfhost/docker-compose.yml @@ -13,6 +13,8 @@ x-app-env : &app-env - DOCKERIZED=${DOCKERIZED:-1} # deprecated - CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-""} - SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT:-"production"} + - ADMIN_EMAIL=${ADMIN_EMAIL:-""} + - LICENSE_ENGINE_BASE_URL=${LICENSE_ENGINE_BASE_URL:-""} # Gunicorn Workers - GUNICORN_WORKERS=${GUNICORN_WORKERS:-2} #DB SETTINGS diff --git a/deploy/selfhost/variables.env b/deploy/selfhost/variables.env index 0a47395c3..c72fec098 100644 --- a/deploy/selfhost/variables.env +++ b/deploy/selfhost/variables.env @@ -64,3 +64,9 @@ FILE_SIZE_LIMIT=5242880 # Gunicorn Workers GUNICORN_WORKERS=2 + +# Admin Email +ADMIN_EMAIL="" + +# License Engine url +LICENSE_ENGINE_BASE_URL="" \ No newline at end of file