Kaynağa Gözat

Funcionando en kubernetes. Con Docker desktop

Celestino Rey 5 ay önce
ebeveyn
işleme
b2171e7c9a

+ 2 - 3
Jenkinsfile

@@ -12,9 +12,8 @@ pipeline {
   
   // Definición de variables de entorno
   environment {
-    NOMBRE_APP = 'jugaralpadel'
-    REGISTRO = 'harbor.reymota.es/jugaralpadel'
-    //REGISTRO = 'registry.reymota.es'
+    NOMBRE_APP = 'trgenerator'
+    REGISTRO = 'harbor.rancher.lab:30002/siemensrad'
   }
 
   // Definición de parámetros

+ 2 - 2
K8S/Makefile

@@ -1,5 +1,5 @@
-export REGISTRO=harbor.reymota.es\/trgenerator
-export IMG_VERSION = alpine-1
+export REGISTRO=harbor.rancher.lab:30002\/siemensrad
+export IMG_VERSION = alpine-14
 export NAMESPACE = trgenerator
 
 # limpia todo

+ 1 - 1
K8S/creaCredencialesRegistry.sh

@@ -1,2 +1,2 @@
 # Añadir lo que salga a la directiva .dockerconfigjson en el fichero de secretos reg-secret.yaml
-cat /home/kubeadmin/.docker/config.json |base64 -w 0
+cat /Users/creylopez/.docker/config.json |base64 -w 0

+ 2 - 2
K8S/env-prod-configmap.yaml

@@ -2,9 +2,9 @@ apiVersion: v1
 data:
   DEBUG: "False"
   APP_VERSION: 16.0.6
-  SQL_DATABASE: reymota
+  SQL_DATABASE: siemens
   SQL_ENGINE: django.db.backends.postgresql
-  SQL_HOST: postgres-cluster-rw.reymota-pg-cluster.svc.cluster.local
+  SQL_HOST: postgres-cluster-rw.siemens-pg-cluster.svc.cluster.local
   SQL_PASSWORD: Dsa-0213
   SQL_PORT: "5432"
   SQL_USER: creylopez

+ 1 - 1
K8S/reg-secret.yaml

@@ -4,5 +4,5 @@ metadata:
   name: myregistrykey
   namespace: <NS>
 data:
-  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJnaXRzZXJ2ZXIucmV5bW90YS5lcyI6IHsKCQkJImF1dGgiOiAiWTNKbGVXeHZjR1Y2T2xKbGVTMHhNVGMyIgoJCX0sCgkJImhhcmJvci5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbmhsZG5wdmJpMTRkWEJvYjNvdE1WSjFkM052IgoJCX0sCgkJInJlZ2lzdHJ5LnJleW1vdGEuZXMiOiB7CgkJCSJhdXRoIjogIlkzSmxlV3h2Y0dWNk9sSmxlUzB4TVRjMiIKCQl9Cgl9Cn0=
+  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJjb3JlLmhhcmJvci5kb21haW46MzAwMDMiOiB7fSwKCQkiY3Iuc2llbWVucy5jb20iOiB7fSwKCQkiaGFyYm9yLnJhbmNoZXIubGFiOjMwMDAyIjoge30sCgkJImhhcmJvci5yZXltb3RhLmxhYjozMDAwMiI6IHt9LAoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjoge30KCX0sCgkiY3JlZHNTdG9yZSI6ICJvc3hrZXljaGFpbiIsCgkiY3VycmVudENvbnRleHQiOiAiZGVza3RvcC1saW51eCIKfQ==
 type: kubernetes.io/dockerconfigjson

+ 1 - 1
K8S/trgenerator-db.yaml

@@ -2,7 +2,7 @@ apiVersion: postgresql.cnpg.io/v1
 kind: Database
 metadata:
   name: trgenerator-db
-  namespace: reymota-pg-cluster
+  namespace: siemens-pg-cluster
 spec:
   name: trgenerator
   owner: creylopez

+ 0 - 15
K8S/trgenerator-deployment.yaml

@@ -29,16 +29,6 @@ spec:
             configMapKeyRef:
               key: DEBUG
               name: env-prod
-        - name: APP_VERSION
-          valueFrom:
-            configMapKeyRef:
-              key: APP_VERSION
-              name: env-prod
-        - name: MES_COMIENZO_TEMPORADA
-          valueFrom:
-            configMapKeyRef:
-              key: MES_COMIENZO_TEMPORADA
-              name: env-prod
         - name: DATABASE
           valueFrom:
             configMapKeyRef:
@@ -74,11 +64,6 @@ spec:
             configMapKeyRef:
               key: SQL_PASSWORD
               name: env-prod        
-        - name: ADMIN_EMAIL
-          valueFrom:
-            configMapKeyRef:
-              key: ADMIN_EMAIL
-              name: env-prod
         ports:
         - containerPort: 8000
           protocol: TCP

+ 20 - 7
src/doc_generator/settings.py

@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
 """
 
 from pathlib import Path
+import os
 
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
 BASE_DIR = Path(__file__).resolve().parent.parent
@@ -25,7 +26,10 @@ SECRET_KEY = 'django-insecure-qb$!mc5&7qcph*kb&j@x$$zce*i9-3es0%9lw$x89n1nl6ncjy
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
 
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = [".rancher.lab", "127.0.0.1", "localhost"]
+
+
+CSRF_TRUSTED_ORIGINS = ["http://*.rancher.lab", "http://trgen.rancher.lab:30343", "http://localhost:30343", "http://127.0.0.1"]
 
 
 # Application definition
@@ -75,16 +79,19 @@ WSGI_APPLICATION = 'doc_generator.wsgi.application'
 
 
 # Database
-# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
+# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
 
 DATABASES = {
     'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': BASE_DIR / 'db.sqlite3',
+        "ENGINE": "django.db.backends.postgresql",
+        "NAME": "trgenerator",
+        "USER": "creylopez",
+        "PASSWORD": "Dsa-0213",
+        "HOST": os.environ.get('SQL_HOST','postgres-cluster-rw.siemens-pg-cluster.svc.cluster.local'),
+        "PORT": "5432",
     }
 }
 
-
 # Password validation
 # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
 
@@ -103,6 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [
     },
 ]
 
+AUTH_USER_MODEL = "siemensusers.SiemensUser"
 
 # Internationalization
 # https://docs.djangoproject.com/en/4.2/topics/i18n/
@@ -119,7 +127,12 @@ USE_TZ = True
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/4.2/howto/static-files/
 
-STATIC_URL = 'static/'
+STATIC_URL = '/static/'
+STATIC_ROOT = BASE_DIR / "staticfiles"
+STATICFILES_DIRS = [BASE_DIR / "static",]
+STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
+MEDIA_URL = '/media/'
+MEDIA_ROOT = BASE_DIR / "media"
 
 # Default primary key field type
 # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
@@ -138,4 +151,4 @@ TINYMCE_DEFAULT_CONFIG = {
                "backcolor removeformat | pagebreak | charmap emoticons | fullscreen  preview save print | "
                "insertfile image media template link anchor codesample | ltr rtl",
     "custom_undo_redo_levels": 10,
-}
+}

+ 10 - 4
src/requirements.txt

@@ -5,14 +5,20 @@ cssselect2==0.8.0
 Django==4.2.29
 django-tinymce==5.0.0
 fonttools==4.60.2
-pillow==11.3.0
+pillow==12.1.1
 pycparser==2.23
 pydyf==0.11.0
 pyphen==0.17.2
 sqlparse==0.5.5
-tinycss2==1.4.0
+tinycss2==1.5.0
 tinyhtml5==2.0.0
 typing_extensions==4.15.0
-weasyprint==66.0
+weasyprint==68.0
 webencodings==0.5.1
-zopfli==0.2.3.post1
+zopfli
+gunicorn
+#zopfli==0.2.3.post1
+psycopg==3.3.2
+psycopg-binary==3.3.2
+psycopg-pool==3.3.0
+whitenoise

+ 0 - 21
src/siemensusers/admin.py

@@ -9,25 +9,6 @@ from django.contrib.auth.admin import UserAdmin
 from siemensusers.models import SiemensUser
 from siemensusers.forms import SiemensUserCreationForm, SiemensUserChangeForm
 
-
-def enviar_email_prueba(modeladmin, request, queryset):
-    for user in queryset:
-        if user.email:
-            send_mail(
-                'Correo de Prueba',
-                'Este es un correo de prueba desde el panel de administración.',
-                'jugaralpadelentreamigos@gmail.com',  # Remitente
-                [user.email],  # Destinatario
-                fail_silently=False,
-            )
-            messages.success(request, f'Se ha enviado un correo de prueba a {user.email}')
-        else:
-            messages.warning(request, f'El usuario {user.username} no tiene un correo registrado.')
-
-
-enviar_email_prueba.short_description = 'Enviar correo de prueba a usuario(s) seleccionado(s)'
-
-
 class SiemensUserAdmin(UserAdmin):
     add_form = SiemensUserCreationForm
     form = SiemensUserChangeForm
@@ -58,7 +39,5 @@ class SiemensUserAdmin(UserAdmin):
     )
     search_fields = ("email", "nombre",)
     ordering = ("email",)
-    actions = [enviar_email_prueba]  # Añadir la acción a la lista de acciones
-
 
 admin.site.register(SiemensUser, SiemensUserAdmin)

+ 1 - 1
src/siemensusers/apps.py

@@ -1,6 +1,6 @@
 from django.apps import AppConfig
 
 
-class ReymotausersConfig(AppConfig):
+class SiemensusersConfig(AppConfig):
     default_auto_field = 'django.db.models.BigAutoField'
     name = 'siemensusers'

+ 1 - 1
src/siemensusers/managers.py

@@ -4,7 +4,7 @@ from django.utils.translation import gettext_lazy as _
 
 class SiemensUserManager(BaseUserManager):
     """
-    ReyMota user model manager where email is the unique identifiers
+    Siemens user model manager where email is the unique identifiers
     for authentication instead of usernames.
     """
     def create_user(self, email, password, **extra_fields):

+ 2 - 0
src/textdocs/views.py

@@ -22,6 +22,8 @@ def document_detail(request, pk):
 def document_create(request):
     """Handles the creation of a new document via a form."""
     if request.method == 'POST':
+        print("Method is POST. Processing form data.") # Log POST request
+
         form = DocumentForm(request.POST)
         if form.is_valid():
             document = form.save()