Skip to content

Commit

Permalink
Merge branch 'docker-plugindir-permissions' into 'main'
Browse files Browse the repository at this point in the history
Docker plugindir permissions

See merge request reportcreator/reportcreator!740
  • Loading branch information
MWedl committed Oct 29, 2024
2 parents 72eec7d + d38ca33 commit fdd9a8c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ docker-compose.yml
node_modules/
**/node_modules/

api/data
api/data
api/src/sysreptor_plugins/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Upcoming
* Experimental plugin system
* Disable static file compression


## v2024.81 - 2024-10-25
* Fix mermaid diagram labels not rendered
* Disable CSP trusted types enforcement because of incompatibilities
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ FROM --platform=$BUILDPLATFORM api-dev AS api-test
# Copy source code
COPY --chown=user:user api/src /app/api/
COPY --chown=user:user plugins /app/plugins/
RUN mkdir -p /app/api/sysreptor_plugins/ && chmod 777 /app/api/sysreptor_plugins/

# Copy generated template rendering script
COPY --from=rendering --chown=user:user /app/rendering/dist /app/rendering/dist/
Expand All @@ -210,8 +211,7 @@ FROM --platform=$BUILDPLATFORM api-test AS api-statics
RUN python3 manage.py collectstatic --no-input --clear
COPY --from=frontend /app/frontend/dist/index.html /app/frontend/dist/static/ /app/api/frontend/static/
RUN mv /app/api/frontend/static/index.html /app/api/frontend/index.html \
&& python3 manage.py collectstatic --no-input --no-post-process \
&& python3 -m whitenoise.compress /app/api/static/ map
&& python3 manage.py collectstatic --no-input --no-post-process

COPY --from=plugin-builder --chown=user:user /app/plugins/ /app/plugins/

Expand Down
11 changes: 5 additions & 6 deletions api/src/reportcreator_api/utils/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ def process_response(self, request, response):

# Cache static files
if request.path.startswith(settings.STATIC_URL) and response.status_code == 200 and not settings.DEBUG:
if any(request.path.endswith(e) for e in ['.html', '.json']) or \
(request.path.startswith(settings.STATIC_URL + 'plugins/') and '/_nuxt/' not in request.path):
# Do not cache for long
cache.patch_cache_control(response, public=True, max_age=2 * 60)
else:
if '/_nuxt/' not in request.path and not any(request.path.endswith(e) for e in ['.html', '.json']):
# Chunk files with unique names. Can be cached for a long time
cache.patch_cache_control(response, public=True, max_age=24 * 3600)
cache.patch_cache_control(response, public=True, max_age=24 * 60 * 60)
else:
# Do not cache for long
cache.patch_cache_control(response, public=True, max_age=1 * 60)
else:
# Do not cache API responses and django views
cache.add_never_cache_headers(response)
Expand Down

0 comments on commit fdd9a8c

Please sign in to comment.