PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
REFACTOR (security): run main application as non-root user
Jim Brännlund8d8754e96c22
diff --git a/Dockerfile b/Dockerfileindex f5faa95a..569538db 100644--- a/Dockerfile+++ b/Dockerfile@@ -159,6 +159,9 @@ RUN groupadd -g 999 postgres || true && \mkdir -p /databasus-data/pgdata && \chown -R postgres:postgres /databasus-data/pgdata+# Create non-root user for the main application process+RUN useradd -r -s /usr/sbin/nologin -u 65532 databasus+WORKDIR /app# Copy Goose from build stage@@ -293,7 +296,12 @@ echo "Setting up data directory permissions..."mkdir -p /databasus-data/pgdatamkdir -p /databasus-data/tempmkdir -p /databasus-data/backups-chown -R postgres:postgres /databasus-data+chown databasus:databasus /databasus-data+chown -R postgres:postgres /databasus-data/pgdata+chown -R databasus:databasus /databasus-data/temp /databasus-data/backups+# Upgrade path: secret.key and instance.json may be owned by root or postgres+# from older images. Re-own them so the non-root main process can read/write.+chown databasus:databasus /databasus-data/secret.key /databasus-data/instance.json 2>/dev/null || truechmod 700 /databasus-data/temp# ========= Start Valkey (internal cache) =========@@ -442,7 +450,7 @@ if [ -n "\${DANGEROUS_VALKEY_HOST:-}" ]; thenecho ""fi-exec ./main+exec gosu databasus ./mainEOFLABEL org.opencontainers.image.source="https://github.com/databasus/databasus"diff --git a/deploy/helm/templates/statefulset.yaml b/deploy/helm/templates/statefulset.yamlindex 7e73a0c3..16df9868 100644--- a/deploy/helm/templates/statefulset.yaml+++ b/deploy/helm/templates/statefulset.yaml@@ -39,10 +39,18 @@ spec:tolerations:{{- toYaml . | nindent 8 }}{{- end }}+ {{- with .Values.podSecurityContext }}+ securityContext:+ {{- toYaml . | nindent 8 }}+ {{- end }}containers:- name: {{ .Chart.Name }}image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"imagePullPolicy: {{ .Values.image.pullPolicy }}+ {{- with .Values.securityContext }}+ securityContext:+ {{- toYaml . | nindent 12 }}+ {{- end }}{{- if .Values.customRootCA }}env:- name: SSL_CERT_FILEdiff --git a/deploy/helm/values.yaml b/deploy/helm/values.yamlindex a0ae702e..269f013d 100644--- a/deploy/helm/values.yaml+++ b/deploy/helm/values.yaml@@ -23,6 +23,16 @@ service:# Headless service for StatefulSetheadless:enabled: true+# Security context for the pod (e.g. fsGroup for volume permissions)+# NOTE: The entrypoint runs as root to bootstrap PostgreSQL and Valkey,+# then drops privileges to a non-root user via gosu. Do not set+# runAsNonRoot or runAsUser here -- it will prevent the container from starting.+podSecurityContext: {}++# Security context for the databasus container+# See podSecurityContext note above regarding root requirement.+securityContext: {}+# Resource limits and requestsresources:requests: