Skip to content

Commit

Permalink
chore: update docker uploads (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar committed Jun 5, 2023
1 parent bffc6a6 commit 50060a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
10 changes: 2 additions & 8 deletions apiserver/plane/api/views/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ def post(self, request, slug):
)

serializer.save(workspace_id=request.user.last_workspace_id)
response_data = serializer.data
if settings.DOCKERIZED and settings.USE_MINIO:
response_data["asset"] = response_data["asset"].replace(settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL)
return Response(response_data, status=status.HTTP_201_CREATED)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
capture_exception(e)
Expand Down Expand Up @@ -85,10 +82,7 @@ def post(self, request):
serializer = FileAssetSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
response_data = serializer.data
if settings.DOCKERIZED and settings.USE_MINIO:
response_data["asset"] = response_data["asset"].replace(settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL)
return Response(response_data, status=status.HTTP_201_CREATED)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
capture_exception(e)
Expand Down
10 changes: 1 addition & 9 deletions apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,6 @@ def post(self, request, slug, project_id, issue_id):
serializer = IssueAttachmentSerializer(data=request.data)
if serializer.is_valid():
serializer.save(project_id=project_id, issue_id=issue_id)
response_data = serializer.data
if (
settings.DOCKERIZED
and settings.USE_MINIO
):
response_data["asset"] = response_data["asset"].replace(
settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL
)
issue_activity.delay(
type="attachment.activity.created",
requested_data=None,
Expand All @@ -836,7 +828,7 @@ def post(self, request, slug, project_id, issue_id):
cls=DjangoJSONEncoder,
),
)
return Response(response_data, status=status.HTTP_201_CREATED)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
capture_exception(e)
Expand Down
12 changes: 8 additions & 4 deletions apiserver/plane/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
SITE_ID = 1

# Set the variable true if running in docker environment
DOCKERIZED = int(os.environ.get(
"DOCKERIZED", 0
)) == 1
DOCKERIZED = int(os.environ.get("DOCKERIZED", 0)) == 1

USE_MINIO = int(os.environ.get("USE_MINIO"), 0) == 1

Expand Down Expand Up @@ -86,7 +84,8 @@
)

if DOCKERIZED and USE_MINIO:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
INSTALLED_APPS += ("storages",)
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
# The AWS access key to use.
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "access-key")
# The AWS secret access key to use.
Expand All @@ -99,6 +98,11 @@
AWS_DEFAULT_ACL = "public-read"
AWS_QUERYSTRING_AUTH = False
AWS_S3_FILE_OVERWRITE = False

# Custom Domain settings
parsed_url = urlparse(os.environ.get("WEB_URL", "http://localhost"))
AWS_S3_CUSTOM_DOMAIN = f"{parsed_url.netloc}/{AWS_STORAGE_BUCKET_NAME}"
AWS_S3_URL_PROTOCOL = f"{parsed_url.scheme}:"
else:
# The AWS region to connect to.
AWS_REGION = os.environ.get("AWS_REGION", "")
Expand Down

0 comments on commit 50060a0

Please sign in to comment.