Docker: фикс прав на /srv/.cache для appuser; X-Trace-Id в раннем 413
This commit is contained in:
@@ -27,6 +27,9 @@ WORKDIR /srv
|
|||||||
COPY --from=builder /install /usr/local
|
COPY --from=builder /install /usr/local
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
|
|
||||||
|
# /srv принадлежит root: кэш под веса создаём и передаём appuser до USER
|
||||||
|
RUN mkdir -p /srv/.cache/torch && chown -R appuser:appuser /srv
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Кэш torch.hub (код dinov2 + веса ~84 МБ) запекаем в образ:
|
# Кэш torch.hub (код dinov2 + веса ~84 МБ) запекаем в образ:
|
||||||
|
|||||||
+3
-1
@@ -105,12 +105,14 @@ def _register_middleware(app: FastAPI) -> None:
|
|||||||
content_length = request.headers.get("Content-Length")
|
content_length = request.headers.get("Content-Length")
|
||||||
limit = app.state.config.max_body_bytes
|
limit = app.state.config.max_body_bytes
|
||||||
if content_length and content_length.isdigit() and int(content_length) > limit:
|
if content_length and content_length.isdigit() and int(content_length) > limit:
|
||||||
return error_response(
|
response = error_response(
|
||||||
413,
|
413,
|
||||||
"PAYLOAD_TOO_LARGE",
|
"PAYLOAD_TOO_LARGE",
|
||||||
f"тело запроса {content_length} байт, максимум {limit}",
|
f"тело запроса {content_length} байт, максимум {limit}",
|
||||||
request.state.trace_id,
|
request.state.trace_id,
|
||||||
)
|
)
|
||||||
|
response.headers["X-Trace-Id"] = request.state.trace_id
|
||||||
|
return response
|
||||||
started = time.perf_counter()
|
started = time.perf_counter()
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
response.headers["X-Trace-Id"] = request.state.trace_id
|
response.headers["X-Trace-Id"] = request.state.trace_id
|
||||||
|
|||||||
Reference in New Issue
Block a user