Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ COPY ./assets /app/assets

ENV PYTHONPATH=/app

# Create non-root user for security best practices
RUN groupadd -g 1001 onyx && \
useradd -u 1001 -g onyx -m -s /bin/bash onyx && \
chown -R onyx:onyx /app && \
chmod 775 /var/log && \
chown onyx:onyx /var/log

# Switch to non-root user
USER onyx

# Default command which does nothing
# This container is used by api server and background which specify their own CMD
CMD ["tail", "-f", "/dev/null"]
10 changes: 10 additions & 0 deletions backend/Dockerfile.model_server
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,14 @@ COPY ./model_server /app/model_server

ENV PYTHONPATH=/app

# Create non-root user for security best practices
RUN groupadd -g 1001 onyx && \
useradd -u 1001 -g onyx -m -s /bin/bash onyx && \
chown -R onyx:onyx /app && \
chmod 775 /var/log && \
chown onyx:onyx /var/log

# Switch to non-root user
USER onyx

CMD ["uvicorn", "model_server.main:app", "--host", "0.0.0.0", "--port", "9000"]
4 changes: 2 additions & 2 deletions deployment/helm/charts/onyx/templates/celery-beat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_beat.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_beat.podSecurityContext) | nindent 8 }}
containers:
- name: celery-beat
securityContext:
{{- toYaml .Values.celery_beat.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_beat.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_docfetching.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_docfetching.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-docfetching
securityContext:
{{- toYaml .Values.celery_worker_docfetching.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_docfetching.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_docprocessing.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_docprocessing.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-docprocessing
securityContext:
{{- toYaml .Values.celery_worker_docprocessing.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_docprocessing.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_heavy.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_heavy.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-heavy
securityContext:
{{- toYaml .Values.celery_worker_heavy.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_heavy.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_light.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_light.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-light
securityContext:
{{- toYaml .Values.celery_worker_light.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_light.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_monitoring.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_monitoring.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-monitoring
securityContext:
{{- toYaml .Values.celery_worker_monitoring.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_monitoring.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_primary.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_primary.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-primary
securityContext:
{{- toYaml .Values.celery_worker_primary.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_primary.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ spec:
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_user_files_indexing.podSecurityContext | nindent 8 }}
{{- toYaml (default .Values.celery_shared.podSecurityContext .Values.celery_worker_user_files_indexing.podSecurityContext) | nindent 8 }}
containers:
- name: celery-worker-user-files-indexing
securityContext:
{{- toYaml .Values.celery_worker_user_files_indexing.securityContext | nindent 12 }}
{{- toYaml (default .Values.celery_shared.securityContext .Values.celery_worker_user_files_indexing.securityContext) | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
securityContext:
{{- toYaml .Values.indexCapability.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Values.indexCapability.name }}
securityContext:
{{- toYaml .Values.indexCapability.securityContext | nindent 10 }}
image: "{{ .Values.indexCapability.image.repository }}:{{ .Values.indexCapability.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command: [ "uvicorn", "model_server.main:app", "--host", "0.0.0.0", "--port", "{{ .Values.indexCapability.containerPorts.server }}", "--limit-concurrency", "{{ .Values.indexCapability.limitConcurrency }}" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ spec:
{{ .key }}: {{ .value }}
{{- end }}
spec:
securityContext:
{{- toYaml .Values.inferenceCapability.podSecurityContext | nindent 8 }}
containers:
- name: model-server-inference
securityContext:
{{- toYaml .Values.inferenceCapability.securityContext | nindent 10 }}
image: "{{ .Values.inferenceCapability.image.repository }}:{{ .Values.inferenceCapability.image.tag | default .Values.global.version }}"
imagePullPolicy: {{ .Values.global.pullPolicy }}
command: [ "uvicorn", "model_server.main:app", "--host", "0.0.0.0", "--port", "{{ .Values.inferenceCapability.containerPorts.server }}" ]
Expand Down
59 changes: 17 additions & 42 deletions deployment/helm/charts/onyx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ inferenceCapability:
podLabels:
- key: app
value: inference-model-server
podSecurityContext:
{}
securityContext:
privileged: false
runAsUser: 1001
resources:
requests:
cpu: 2000m
Expand Down Expand Up @@ -118,6 +123,11 @@ indexCapability:
# Overrides the image tag whose default is the chart appVersion.
tag: ""
limitConcurrency: 10
podSecurityContext:
{}
securityContext:
privileged: false
runAsUser: 1001
resources:
requests:
cpu: 2000m
Expand Down Expand Up @@ -173,13 +183,13 @@ webserver:
# fsGroup: 2000

securityContext:
{}
privileged: false
runAsUser: 1001
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

containerPorts:
server: 3000
Expand Down Expand Up @@ -318,6 +328,11 @@ celery_shared:
periodSeconds: 60
failureThreshold: 5
timeoutSeconds: 3
podSecurityContext:
{}
securityContext:
privileged: false
runAsUser: 1001

celery_beat:
replicaCount: 1
Expand All @@ -327,11 +342,6 @@ celery_beat:
app: celery-beat
deploymentLabels:
app: celery-beat
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 1000m
Expand All @@ -355,11 +365,6 @@ celery_worker_heavy:
app: celery-worker-heavy
deploymentLabels:
app: celery-worker-heavy
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 1000m
Expand All @@ -383,11 +388,6 @@ celery_worker_docprocessing:
app: celery-worker-docprocessing
deploymentLabels:
app: celery-worker-docprocessing
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 500m
Expand All @@ -411,11 +411,6 @@ celery_worker_light:
app: celery-worker-light
deploymentLabels:
app: celery-worker-light
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 1000m
Expand All @@ -439,11 +434,6 @@ celery_worker_monitoring:
app: celery-worker-monitoring
deploymentLabels:
app: celery-worker-monitoring
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 500m
Expand All @@ -467,11 +457,6 @@ celery_worker_primary:
app: celery-worker-primary
deploymentLabels:
app: celery-worker-primary
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 1000m
Expand All @@ -495,11 +480,6 @@ celery_worker_user_files_indexing:
app: celery-worker-user-files-indexing
deploymentLabels:
app: celery-worker-user-files-indexing
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 2000m
Expand Down Expand Up @@ -546,11 +526,6 @@ celery_worker_docfetching:
app: celery-worker-docfetching
deploymentLabels:
app: celery-worker-docfetching
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources:
requests:
cpu: 500m
Expand Down