Browse Source

Junto K8S y Openshift

main
Celestino Rey 8 months ago
parent
commit
cccf3c061f
33 changed files with 3312 additions and 5 deletions
  1. +73
    -0
      Dockerfile.k8s
  2. +1
    -0
      K8S/.gitignore
  3. +56
    -0
      K8S/Makefile
  4. +2
    -0
      K8S/borraNS.sh
  5. +7
    -0
      K8S/creaDirs.sh
  6. +52
    -0
      K8S/db-deployment.yaml
  7. +17
    -0
      K8S/db-service.yaml
  8. +1
    -0
      K8S/entra.sh
  9. +1
    -0
      K8S/entraPsql.sh
  10. +11
    -0
      K8S/env-prod-configmap.yaml
  11. +11
    -0
      K8S/env-prod-db-configmap.yaml
  12. +7
    -0
      K8S/namespace.yaml
  13. +46
    -0
      K8S/nginx-deployment-limpio.yaml
  14. +46
    -0
      K8S/nginx-deployment.yaml
  15. +20
    -0
      K8S/nginx-service.yaml
  16. +13
    -0
      K8S/postgres-data-persistentvolumeclaim.yaml
  17. +104
    -0
      K8S/pv-local-reymota.yaml
  18. +8
    -0
      K8S/reg-secret.yaml
  19. +2466
    -0
      K8S/reymota-0.18.sql
  20. +139
    -0
      K8S/reymota-deployment-limpio.yaml
  21. +89
    -0
      K8S/reymota-deployment.yaml
  22. +31
    -0
      K8S/reymota-ingress.yaml
  23. +63
    -0
      K8S/reymota-prod-persistentvolumeclaim.yaml
  24. +13
    -0
      K8S/static-volume-persistentvolumeclaim.yaml
  25. +1
    -0
      K8S/verImg.sh
  26. +8
    -0
      Makefile
  27. +0
    -0
      Shells/borraDB.sh
  28. +0
    -0
      Shells/creaDB.sh
  29. +0
    -0
      Shells/entra.sh
  30. +0
    -0
      Shells/nuevaapp.sh
  31. +20
    -0
      entrypoint.sh
  32. +1
    -0
      src/reymota/context_processors.py
  33. +5
    -5
      src/reymota/settings.py

+ 73
- 0
Dockerfile.k8s View File

@ -0,0 +1,73 @@
# syntax=docker/dockerfile:1
##################
# BUILDER #
##################
FROM python:3.11.4-slim-buster AS builder
# set work directory
WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc
# lint
RUN pip install --upgrade pip
RUN pip install flake8==6.0.0
COPY . /app/
RUN flake8 --ignore=E501,F401,E126 .
COPY ./src/requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
##################
# FINAL #
##################
FROM python:3.11.4-slim-buster
# create directory for the app user
RUN mkdir -p /app
# create the app user
#RUN addgroup --system app && adduser --system --group app
# create the appropriate directories
ENV APP_HOME=/app
RUN mkdir -p $APP_HOME
#RUN mkdir -p $APP_HOME/staticfiles
#RUN mkdir -p $APP_HOME/mediafiles
WORKDIR $APP_HOME
# install system dependencies
RUN apt-get update && apt-get install -y sqlite3 netcat vim procps curl jq
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
# copy entrypoint.sh
COPY ./entrypoint.sh .
# copy project
COPY . $APP_HOME
# chown all the files to the app user
#RUN chown -R app:app $APP_HOME
# change to the app user
#USER app
WORKDIR $APP_HOME/src
# run entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

+ 1
- 0
K8S/.gitignore View File

@ -0,0 +1 @@
temp.json

+ 56
- 0
K8S/Makefile View File

@ -0,0 +1,56 @@
export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':')
export REGISTRY=registry.reymota.es
export IMG_VERSION = 0.56
export IMG_NGINX_VERSION = 1.0
# limpia todo
all: imagen clean install
imagen:
cd ../; make
install:
-kubectl create -f namespace.yaml
-kubectl create -f reg-secret.yaml
-kubectl create -f env-prod-configmap.yaml
-kubectl create -f env-prod-db-configmap.yaml
-kubectl create -f pv-local-reymota.yaml
-kubectl create -f reymota-prod-persistentvolumeclaim.yaml
-kubectl create -f static-volume-persistentvolumeclaim.yaml
-kubectl create -f postgres-data-persistentvolumeclaim.yaml
-kubectl create -f db-deployment.yaml
-kubectl create -f db-service.yaml
-envsubst < reymota-deployment.yaml |kubectl create -f -
-envsubst < nginx-deployment.yaml |kubectl create -f -
-kubectl create -f nginx-service.yaml
-kubectl create -f reymota-ingress.yaml
clean:
-envsubst < nginx-deployment.yaml |kubectl delete -f -
-kubectl delete -f nginx-service.yaml
-envsubst < reymota-deployment.yaml |kubectl delete -f -
-kubectl delete -f db-deployment.yaml
-kubectl delete -f db-service.yaml
-kubectl delete -f env-prod-configmap.yaml
-kubectl delete -f env-prod-db-configmap.yaml
-kubectl delete -f postgres-data-persistentvolumeclaim.yaml
-kubectl delete -f static-volume-persistentvolumeclaim.yaml
-kubectl delete -f reymota-prod-persistentvolumeclaim.yaml
-kubectl delete -f pv-local-reymota.yaml
-kubectl delete -f reg-secret.yaml
-kubectl delete -f namespace.yaml
nginx:
cd ../nginx; make
backup:
kubectl --kubeconfig /home/creylopez/.kube/config -n reymota exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=reymota > reymota-$(IMG_VERSION).sql
muestra:
-envsubst < reymota-deployment.yaml > /tmp/deployment.yaml

+ 2
- 0
K8S/borraNS.sh View File

@ -0,0 +1,2 @@
( NAMESPACE=reymota; kubectl proxy & kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json; curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize; )

+ 7
- 0
K8S/creaDirs.sh View File

@ -0,0 +1,7 @@
sudo mkdir -p /mnt/Externo/reymota/media
sudo mkdir -p /mnt/Externo/reymota/migrations/lyrics
sudo mkdir -p /mnt/Externo/reymota/migrations/libros
sudo mkdir -p /mnt/Externo/reymota/migrations/repostajes
sudo mkdir -p /mnt/Externo/reymota/migrations/reymotausers
sudo mkdir -p /mnt/Externo/reymota/static
sudo mkdir -p /mnt/Externo/reymota/pg

+ 52
- 0
K8S/db-deployment.yaml View File

@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: db
name: db
namespace: reymota
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: db
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: db
spec:
containers:
- env:
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: env-prod-db
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
key: POSTGRES_PASSWORD
name: env-prod-db
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: env-prod-db
image: postgres:15
name: db
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-data
restartPolicy: Always
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-data

+ 17
- 0
K8S/db-service.yaml View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: db
name: db
namespace: reymota
spec:
ports:
- name: "5432"
port: 5432
targetPort: 5432
selector:
io.kompose.service: db

+ 1
- 0
K8S/entra.sh View File

@ -0,0 +1 @@
kubectl -n reymota exec -ti deployment.apps/reymota -- /bin/bash

+ 1
- 0
K8S/entraPsql.sh View File

@ -0,0 +1 @@
kubectl -n reymota exec -ti deployment.apps/db -- psql --username=creylopez --dbname=reymota

+ 11
- 0
K8S/env-prod-configmap.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
data:
DEBUG: "False"
ENTORNO: "Producción"
SECRET_KEY: change_me
kind: ConfigMap
metadata:
labels:
io.kompose.service: web-env-prod
name: env-prod
namespace: reymota

+ 11
- 0
K8S/env-prod-db-configmap.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
data:
POSTGRES_DB: reymota
POSTGRES_PASSWORD: Dsa-0213
POSTGRES_USER: creylopez
kind: ConfigMap
metadata:
labels:
io.kompose.service: db-env-prod-db
name: env-prod-db
namespace: reymota

+ 7
- 0
K8S/namespace.yaml View File

@ -0,0 +1,7 @@
###################################################
# Namespace reymota
###################################################
apiVersion: v1
kind: Namespace
metadata:
name: reymota

+ 46
- 0
K8S/nginx-deployment-limpio.yaml View File

@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: nginx
name: nginx
namespace: reymota
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: nginx
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: nginx
spec:
containers:
- image: registry.reymota.es/nginx-reymota-x86_64:1.0
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /app/reymota/staticfiles
name: static-volume
- mountPath: /app/reymota/mediafiles
name: reymota-media
imagePullSecrets:
- name: myregistrykey
restartPolicy: Always
volumes:
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
- name: reymota-media
persistentVolumeClaim:
claimName: reymota-media

+ 46
- 0
K8S/nginx-deployment.yaml View File

@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: nginx
name: nginx
namespace: reymota
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: nginx
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: nginx
spec:
containers:
- image: $REGISTRY/nginx-reymota-$ARQUITECTURA:$IMG_NGINX_VERSION
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /app/reymota/staticfiles
name: static-volume
- mountPath: /app/reymota/mediafiles
name: reymota-media
imagePullSecrets:
- name: myregistrykey
restartPolicy: Always
volumes:
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
- name: reymota-media
persistentVolumeClaim:
claimName: reymota-media

+ 20
- 0
K8S/nginx-service.yaml View File

@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.34.0 (cbf2835db)
labels:
io.kompose.service: nginx
name: nginx
namespace: reymota
spec:
type: NodePort
ports:
- name: "1337"
port: 1337
nodePort: 30341
targetPort: 80
selector:
io.kompose.service: nginx

+ 13
- 0
K8S/postgres-data-persistentvolumeclaim.yaml View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
io.kompose.service: postgres-data
name: postgres-data
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi

+ 104
- 0
K8S/pv-local-reymota.yaml View File

@ -0,0 +1,104 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-media-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/media"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-lyrics-migrations-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 50Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/migrations/lyrics"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-libros-migrations-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 51Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/migrations/libros"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-repostajes-migrations-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 52Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/migrations/repostajes"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-reymotausers-migrations-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 53Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/migrations/reymotausers"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-static-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 70Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/static"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: reymota-pg-folder
namespace: reymota
labels:
app: reymota
spec:
capacity:
storage: 200Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/Externo/reymota/pg"

+ 8
- 0
K8S/reg-secret.yaml View File

@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: myregistrykey
namespace: reymota
data:
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9
type: kubernetes.io/dockerconfigjson

+ 2466
- 0
K8S/reymota-0.18.sql
File diff suppressed because it is too large
View File


+ 139
- 0
K8S/reymota-deployment-limpio.yaml View File

@ -0,0 +1,139 @@
apiVersion: v1
kind: Service
metadata:
name: reymota
namespace: reymota
spec:
ports:
- name: "8000"
port: 8000
targetPort: 8000
selector:
app: reymota
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: reymota
namespace: reymota
labels:
app: reymota
spec:
replicas: 1
selector:
matchLabels:
app: reymota
strategy:
type: Recreate
template:
metadata:
labels:
app: reymota
spec:
containers:
- args:
- gunicorn
- reymota.wsgi:application
- --bind
- 0.0.0.0:8000
name: reymota
image: registry.reymota.es/reymota-x86_64:0.24
env:
- name: VERSION
value: "0.24"
- name: ENVIRONMENT
valueFrom:
configMapKeyRef:
key: ENTORNO
name: env-prod
- name: DEBUG
valueFrom:
configMapKeyRef:
key: DEBUG
name: env-prod
- name: DJANGO_ALLOWED_HOSTS
valueFrom:
configMapKeyRef:
key: DJANGO_ALLOWED_HOSTS
name: env-prod
- name: CSRF_TRUSTED_ORIGINS
valueFrom:
configMapKeyRef:
key: CSRF_TRUSTED_ORIGINS
name: env-prod
- name: SECRET_KEY
valueFrom:
configMapKeyRef:
key: SECRET_KEY
name: env-prod
- name: DATABASE
valueFrom:
configMapKeyRef:
key: DATABASE
name: env-prod
- name: SQL_HOST
valueFrom:
configMapKeyRef:
key: SQL_HOST
name: env-prod
- name: SQL_PORT
valueFrom:
configMapKeyRef:
key: SQL_PORT
name: env-prod
- name: SQL_ENGINE
valueFrom:
configMapKeyRef:
key: SQL_ENGINE
name: env-prod
- name: SQL_DATABASE
valueFrom:
configMapKeyRef:
key: SQL_DATABASE
name: env-prod
- name: SQL_USER
valueFrom:
configMapKeyRef:
key: SQL_USER
name: env-prod
- name: SQL_PASSWORD
valueFrom:
configMapKeyRef:
key: SQL_PASSWORD
name: env-prod
ports:
- containerPort: 8000
protocol: TCP
volumeMounts:
- mountPath: /app/reymota/mediafiles
name: reymota-media
- mountPath: /app/reymota/lyrics/migrations
name: reymota-lyrics-migrations
- mountPath: /app/reymota/repostajes/migrations
name: reymota-repostajes-migrations
- mountPath: /app/reymota/reymotausers/migrations
name: reymota-reymotausers-migrations
- mountPath: /app/reymota/staticfiles
name: static-volume
imagePullSecrets:
- name: myregistrykey
restartPolicy: Always
volumes:
- name: reymota-media
persistentVolumeClaim:
claimName: reymota-media
- name: reymota-lyrics-migrations
persistentVolumeClaim:
claimName: reymota-lyrics-migrations
- name: reymota-repostajes-migrations
persistentVolumeClaim:
claimName: reymota-repostajes-migrations
- name: reymota-reymotausers-migrations
persistentVolumeClaim:
claimName: reymota-reymotausers-migrations
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
status: {}

+ 89
- 0
K8S/reymota-deployment.yaml View File

@ -0,0 +1,89 @@
apiVersion: v1
kind: Service
metadata:
name: reymota
namespace: reymota
spec:
ports:
- name: "8000"
port: 8000
targetPort: 8000
selector:
app: reymota
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: reymota
namespace: reymota
labels:
app: reymota
spec:
replicas: 1
selector:
matchLabels:
app: reymota
strategy:
type: Recreate
template:
metadata:
labels:
app: reymota
spec:
containers:
- args:
- gunicorn
- reymota.wsgi:application
- --bind
- 0.0.0.0:8000
name: reymota
image: $REGISTRY/reymota-$ARQUITECTURA:$IMG_VERSION
env:
- name: VERSION
value: "$IMG_VERSION"
- name: ENVIRONMENT
valueFrom:
configMapKeyRef:
key: ENTORNO
name: env-prod
- name: DEBUG
valueFrom:
configMapKeyRef:
key: DEBUG
name: env-prod
ports:
- containerPort: 8000
protocol: TCP
volumeMounts:
- mountPath: /app/reymota/mediafiles
name: reymota-media
- mountPath: /app/reymota/lyrics/migrations
name: reymota-lyrics-migrations
- mountPath: /app/reymota/repostajes/migrations
name: reymota-repostajes-migrations
- mountPath: /app/reymota/reymotausers/migrations
name: reymota-reymotausers-migrations
- mountPath: /app/reymota/staticfiles
name: static-volume
imagePullSecrets:
- name: myregistrykey
restartPolicy: Always
volumes:
- name: reymota-media
persistentVolumeClaim:
claimName: reymota-media
- name: reymota-lyrics-migrations
persistentVolumeClaim:
claimName: reymota-lyrics-migrations
- name: reymota-repostajes-migrations
persistentVolumeClaim:
claimName: reymota-repostajes-migrations
- name: reymota-reymotausers-migrations
persistentVolumeClaim:
claimName: reymota-reymotausers-migrations
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
status: {}

+ 31
- 0
K8S/reymota-ingress.yaml View File

@ -0,0 +1,31 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
generation: 1
managedFields:
- apiVersion: networking.k8s.io/v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:defaultBackend:
.: {}
f:service:
.: {}
f:name: {}
f:port: {}
f:rules: {}
manager: rancher
operation: Update
name: reymota
namespace: reymota
spec:
defaultBackend:
service:
name: nginx
port:
number: 1337
ingressClassName: nginx
rules:
- host: reymota.rancher.reymota.lab
status:
loadBalancer: {}

+ 63
- 0
K8S/reymota-prod-persistentvolumeclaim.yaml View File

@ -0,0 +1,63 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: reymota-media
name: reymota-media
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: reymota-lyrics-migrations
name: reymota-lyrics-migrations
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
status: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: reymota-repostajes-migrations
name: reymota-repostajes-migrations
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 52Mi
status: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: reymota-reymotausers-migrations
name: reymota-reymotausers-migrations
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 53Mi
status: {}

+ 13
- 0
K8S/static-volume-persistentvolumeclaim.yaml View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
io.kompose.service: static-volume
name: static-volume
namespace: reymota
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 70Mi

+ 1
- 0
K8S/verImg.sh View File

@ -0,0 +1 @@
docker run -it registry.reymota.es/reymota-x86_64:0.1 bash

+ 8
- 0
Makefile View File

@ -0,0 +1,8 @@
install:
echo "Creando imagen con version '${IMG_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'"
docker build --no-cache -t ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION} -f Dockerfile.k8s .
docker push ${REGISTRY}/reymota-${ARQUITECTURA}:${IMG_VERSION}

borraDB.sh → Shells/borraDB.sh View File


creaDB.sh → Shells/creaDB.sh View File


entra.sh → Shells/entra.sh View File


nuevaapp.sh → Shells/nuevaapp.sh View File


+ 20
- 0
entrypoint.sh View File

@ -0,0 +1,20 @@
#!/bin/bash
if [ "$DATABASE" = "postgres" ]
then
echo "Waiting for postgres..."
while ! nc -z $SQL_HOST $SQL_PORT; do
sleep 0.1
done
echo "PostgreSQL started"
else
echo "la base de datos no es postgres: '$DATABASE'"
fi
python manage.py collectstatic --noinput
#python manage.py flush --no-input
#python manage.py migrate
exec "$@"

+ 1
- 0
src/reymota/context_processors.py View File

@ -1,5 +1,6 @@
from django.conf import settings from django.conf import settings
def app_version(request): def app_version(request):
return { return {
'APP_VERSION': settings.APP_VERSION 'APP_VERSION': settings.APP_VERSION


+ 5
- 5
src/reymota/settings.py View File

@ -30,7 +30,7 @@ SECRET_KEY = 'django-insecure-vu#zk4g8pj-qoov#8^i$&s8n_ipp2r3h+o$z1w(1%d=6+i@erm
# DEBUG = True # DEBUG = True
DEBUG = os.environ["DEBUG"] == 'True' DEBUG = os.environ["DEBUG"] == 'True'
ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "reymota.es"]
ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "reymota.es", ".reymota.lab"]
# Application definition # Application definition
@ -45,6 +45,8 @@ INSTALLED_APPS = [
'repostajes', 'repostajes',
'reymotausers', 'reymotausers',
'lyrics', 'lyrics',
'rest_framework',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -94,7 +96,7 @@ DATABASES = {
"HOST": "postgresql", "HOST": "postgresql",
"PORT": "5432", "PORT": "5432",
} }
}
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
@ -150,8 +152,7 @@ AUTH_USER_MODEL = "reymotausers.ReyMotaUser"
MEDIA_ROOT = BASE_DIR / "mediafiles" MEDIA_ROOT = BASE_DIR / "mediafiles"
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab"]
CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "https://reymota.es", "http://reymota.rancher.reymota.lab"]
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
@ -206,4 +207,3 @@ LOGGING = {
}, },
}, },
} }

Loading…
Cancel
Save