Improve Laravel deploy support and add .env import to deploy wizard.
Set Laravel DB env vars in Helm and Kubernetes, fix default port to 80 with a storage-aware entrypoint, and let users upload a .env file during deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -53,6 +53,15 @@ spec:
|
||||
key: password
|
||||
- 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
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.database.enabled (eq .Values.database.type "mysql") }}
|
||||
- name: DB_HOST
|
||||
@@ -73,6 +82,15 @@ spec:
|
||||
key: password
|
||||
- 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
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.database.enabled (eq .Values.database.type "mariadb") }}
|
||||
- name: DB_HOST
|
||||
@@ -93,6 +111,15 @@ spec:
|
||||
key: password
|
||||
- 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
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and .Values.database.enabled (eq .Values.database.type "mongodb") }}
|
||||
- name: DB_HOST
|
||||
@@ -115,6 +142,15 @@ spec:
|
||||
value: "mongodb://$(DB_USER):$(DB_PASSWORD)@{{ include "cloudhost-app.dbDeploymentName" . }}:27017/{{ include "cloudhost-app.dbName" . }}?authSource=admin"
|
||||
- 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
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- /* Redis connection env vars */}}
|
||||
{{- if .Values.redis.enabled }}
|
||||
|
||||
@@ -997,7 +997,7 @@ CMD ["sh", "-c", "if [ \\"$(cat /app/.mode)\\" = \\"standalone\\" ] && [ -f serv
|
||||
|
||||
private laravelDockerfile(app: Application): string {
|
||||
const phpVersion = app.phpVersion || '8.3';
|
||||
const port = app.port || 8000;
|
||||
const port = app.port || 80;
|
||||
return `# --- Build stage ---
|
||||
FROM composer:2 AS composer
|
||||
WORKDIR /app
|
||||
@@ -1066,8 +1066,16 @@ RUN mkdir -p storage/logs storage/framework/cache storage/framework/sessions sto
|
||||
RUN php artisan config:cache && php artisan route:cache && php artisan view:cache || true
|
||||
RUN php artisan storage:link || true
|
||||
|
||||
RUN echo '#!/bin/sh' > /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
echo 'set -e' >> /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
echo 'cd /var/www/html' >> /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
echo 'mkdir -p storage/logs storage/framework/cache storage/framework/sessions storage/framework/views' >> /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
echo 'chown -R www-data:www-data storage' >> /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
echo 'exec /usr/bin/supervisord -c /etc/supervisord.conf' >> /usr/local/bin/cloudhost-laravel-entrypoint.sh && \\
|
||||
chmod +x /usr/local/bin/cloudhost-laravel-entrypoint.sh
|
||||
|
||||
EXPOSE ${port}
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
||||
CMD ["/usr/local/bin/cloudhost-laravel-entrypoint.sh"]
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,6 +431,16 @@ export class KubernetesService implements OnModuleInit {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
(ctx.runtime === AppRuntime.LARAVEL || ctx.runtime === AppRuntime.PHP) &&
|
||||
ctx.databaseType !== DatabaseType.NONE
|
||||
) {
|
||||
extraEnv.push(
|
||||
{ name: 'DB_DATABASE', value: ctx.appName.replace(/-/g, '_') },
|
||||
{ name: 'DB_USERNAME', valueFrom: { secretKeyRef: { name: `${ctx.appName}-db-secret`, key: 'username' } } },
|
||||
);
|
||||
}
|
||||
|
||||
// Redis connection env vars
|
||||
if (ctx.enableRedis) {
|
||||
const redisName = `${ctx.appName}-redis`;
|
||||
|
||||
Reference in New Issue
Block a user