fix(laravel): apply runtime DB config and startup entrypoint

Laravel images no longer bake config:cache at build time, which ignored
K8s DB env vars. Add DB_CONNECTION, clear config on boot, generate APP_KEY
when missing, run migrations, and rebuild caches at container start.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-05-15 00:30:17 +03:30
parent cca6cdc1a5
commit 5fd4069821
4 changed files with 41 additions and 33 deletions
@@ -54,13 +54,7 @@ spec:
- name: DATABASE_URL
value: "postgresql://$(DB_USER):$(DB_PASSWORD)@{{ include "cloudhost-app.dbDeploymentName" . }}:5432/{{ include "cloudhost-app.dbName" . }}"
{{- if or (eq .Values.app.runtime "laravel") (eq .Values.app.runtime "php") }}
- name: DB_DATABASE
value: {{ include "cloudhost-app.dbName" . }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ $name }}-db-secret
key: username
{{ include "cloudhost-app.laravelDbEnv" . }}
{{- end }}
{{- end }}
{{- if and .Values.database.enabled (eq .Values.database.type "mysql") }}
@@ -83,13 +77,7 @@ spec:
- name: DATABASE_URL
value: "mysql://$(DB_USER):$(DB_PASSWORD)@{{ include "cloudhost-app.dbDeploymentName" . }}:3306/{{ include "cloudhost-app.dbName" . }}"
{{- if or (eq .Values.app.runtime "laravel") (eq .Values.app.runtime "php") }}
- name: DB_DATABASE
value: {{ include "cloudhost-app.dbName" . }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ $name }}-db-secret
key: username
{{ include "cloudhost-app.laravelDbEnv" . }}
{{- end }}
{{- end }}
{{- if and .Values.database.enabled (eq .Values.database.type "mariadb") }}
@@ -112,13 +100,7 @@ spec:
- name: DATABASE_URL
value: "mysql://$(DB_USER):$(DB_PASSWORD)@{{ include "cloudhost-app.dbDeploymentName" . }}:3306/{{ include "cloudhost-app.dbName" . }}"
{{- if or (eq .Values.app.runtime "laravel") (eq .Values.app.runtime "php") }}
- name: DB_DATABASE
value: {{ include "cloudhost-app.dbName" . }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ $name }}-db-secret
key: username
{{ include "cloudhost-app.laravelDbEnv" . }}
{{- end }}
{{- end }}
{{- if and .Values.database.enabled (eq .Values.database.type "mongodb") }}
@@ -143,13 +125,7 @@ spec:
- name: DATABASE_URL
value: "mongodb://$(DB_USER):$(DB_PASSWORD)@{{ include "cloudhost-app.dbDeploymentName" . }}:27017/{{ include "cloudhost-app.dbName" . }}?authSource=admin"
{{- if or (eq .Values.app.runtime "laravel") (eq .Values.app.runtime "php") }}
- name: DB_DATABASE
value: {{ include "cloudhost-app.dbName" . }}
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ $name }}-db-secret
key: username
{{ include "cloudhost-app.laravelDbEnv" . }}
{{- end }}
{{- end }}
{{- /* Redis connection env vars */}}