| @ -1,69 +1,31 @@ | |||||
| # syntax=docker/dockerfile:1 | |||||
| ################## | |||||
| # BUILDER # | |||||
| ################## | |||||
| # yup, python 3.11! | |||||
| FROM python:3.11-slim | |||||
| FROM python:3.11.4-slim-buster AS builder | |||||
| # install nginx | |||||
| RUN apt-get update && apt-get install nginx -y | |||||
| # copy our nginx configuration to overwrite nginx defaults | |||||
| COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf | |||||
| # link nginx logs to container stdout | |||||
| RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log | |||||
| # 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,W391 . | |||||
| COPY ./requirements.txt . | |||||
| RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt | |||||
| ################## | |||||
| # FINAL # | |||||
| ################## | |||||
| # copy the django code | |||||
| COPY ./src ./app | |||||
| FROM python:3.11.4-slim-buster | |||||
| RUN chgrp -R 0 ./app && chmod -R g=u ./app | |||||
| RUN chgrp -R 0 /var/lib/nginx && chmod -R g=u /var/lib/nginx | |||||
| # change our working directory to the django projcet roo | |||||
| WORKDIR /app | |||||
| # create directory for the app user | |||||
| ENV APP_HOME=/app | |||||
| RUN mkdir -p $APP_HOME/gestion_reservas/staticfiles | |||||
| # create the app user | |||||
| RUN addgroup --system app && adduser --system --group app | |||||
| # create the appropriate directories | |||||
| WORKDIR $APP_HOME | |||||
| # install system dependencies | |||||
| RUN apt-get update && apt-get install -y sqlite3 netcat vim | |||||
| 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 | |||||
| # create virtual env (notice the location?) | |||||
| # update pip | |||||
| # install requirements | |||||
| RUN python -m venv /opt/venv && \ | |||||
| /opt/venv/bin/python -m pip install pip --upgrade && \ | |||||
| /opt/venv/bin/python -m pip install -r requirements.txt | |||||
| # change to the app user | |||||
| USER app | |||||
| WORKDIR $APP_HOME/gestion_reservas | |||||
| # make our entrypoint.sh executable | |||||
| RUN chmod +x config/entrypoint.sh | |||||
| # run entrypoint.sh | |||||
| ENTRYPOINT ["/app/entrypoint.sh"] | |||||
| # execute our entrypoint.sh file | |||||
| CMD ["./config/entrypoint.sh"] | |||||
| @ -1,63 +0,0 @@ | |||||
| export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') | |||||
| #export REGISTRY=localhost:5000 | |||||
| export REGISTRY=registry.reymota.es | |||||
| export IMG_VERSION = 0.33 | |||||
| export IMG_NGINX_VERSION = 2.3 | |||||
| # 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-jugaralpadel.yaml | |||||
| -kubectl create -f jugaralpadel-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 < jugaralpadel-deployment.yaml |kubectl create -f - | |||||
| -envsubst < nginx-deployment.yaml |kubectl create -f - | |||||
| -kubectl create -f nginx-service.yaml | |||||
| clean: | |||||
| -envsubst < nginx-deployment.yaml |kubectl delete -f - | |||||
| -kubectl delete -f nginx-service.yaml | |||||
| -envsubst < jugaralpadel-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 jugaralpadel-prod-persistentvolumeclaim.yaml | |||||
| -kubectl delete -f pv-local-jugaralpadel.yaml | |||||
| -kubectl delete -f reg-secret.yaml | |||||
| -kubectl delete -f namespace.yaml | |||||
| nginx: | |||||
| cd ../nginx; make | |||||
| verimg: | |||||
| docker run -it ${REGISTRY}/jugaralpadel-${ARQUITECTURA}:${IMG_VERSION} bash | |||||
| backup: | |||||
| kubectl --kubeconfig /home/creylopez/.kube/config -n jugaralpadel exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=jugaralpadel > jugaralpadel-$(IMG_VERSION).sql | |||||
| muestra: | |||||
| -envsubst < jugaralpadel-deployment.yaml > /tmp/deployment.yaml | |||||
| @ -1,58 +0,0 @@ | |||||
| export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') | |||||
| export REGISTRY=localhost:30500 | |||||
| #export REGISTRY=registry.reymota.es | |||||
| export IMG_VERSION = 1.25 | |||||
| export IMG_NGINX_VERSION = 2.4 | |||||
| # 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-local.yaml | |||||
| -kubectl create -f env-prod-db-configmap.yaml | |||||
| -kubectl create -f pv-local-jugaralpadel.yaml | |||||
| -kubectl create -f jugaralpadel-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 < jugaralpadel-deployment.yaml |kubectl create -f - | |||||
| -envsubst < nginx-deployment.yaml |kubectl create -f - | |||||
| -kubectl create -f nginx-service.yaml | |||||
| clean: | |||||
| -envsubst < nginx-deployment.yaml |kubectl delete -f - | |||||
| -kubectl delete -f nginx-service.yaml | |||||
| -envsubst < jugaralpadel-deployment.yaml |kubectl delete -f - | |||||
| -kubectl delete -f db-deployment.yaml | |||||
| -kubectl delete -f db-service.yaml | |||||
| -kubectl delete -f env-prod-configmap-local.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 jugaralpadel-prod-persistentvolumeclaim.yaml | |||||
| -kubectl delete -f pv-local-jugaralpadel.yaml | |||||
| -kubectl delete -f reg-secret.yaml | |||||
| -kubectl delete -f namespace.yaml | |||||
| nginx: | |||||
| cd ../nginx; make | |||||
| verimg: | |||||
| docker run -it ${REGISTRY}/jugaralpadel-${ARQUITECTURA}:${IMG_VERSION} bash | |||||
| backup: | |||||
| kubectl --kubeconfig /home/creylopez/.kube/config -n jugaralpadel exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=jugaralpadel > jugaralpadel-$(IMG_VERSION).sql | |||||
| @ -1,5 +0,0 @@ | |||||
| sudo mkdir -p /mnt/Externo/jugaralpadel/media | |||||
| sudo mkdir -p /mnt/Externo/jugaralpadel/migrations/eventos | |||||
| sudo mkdir -p /mnt/Externo/jugaralpadel/migrations/reymotausers | |||||
| sudo mkdir -p /mnt/Externo/jugaralpadel/static | |||||
| sudo mkdir -p /mnt/Externo/jugaralpadel/pg | |||||
| @ -1,54 +0,0 @@ | |||||
| 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: jugaralpadel | |||||
| spec: | |||||
| securityContext: | |||||
| fsGroup: GROUP_ID | |||||
| 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:z | |||||
| name: postgres-data | |||||
| restartPolicy: Always | |||||
| volumes: | |||||
| - name: postgres-data | |||||
| persistentVolumeClaim: | |||||
| claimName: postgres-data | |||||
| @ -1,17 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: Service | |||||
| metadata: | |||||
| annotations: | |||||
| kompose.cmd: kompose convert | |||||
| kompose.version: 1.34.0 (cbf2835db) | |||||
| labels: | |||||
| io.kompose.service: db | |||||
| name: db | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| ports: | |||||
| - name: "5432" | |||||
| port: 5432 | |||||
| targetPort: 5432 | |||||
| selector: | |||||
| io.kompose.service: db | |||||
| @ -1 +0,0 @@ | |||||
| kubectl -n jugaralpadel exec -ti deployment.apps/jugaralpadel -- /bin/bash | |||||
| @ -1 +0,0 @@ | |||||
| kubectl -n jugaralpadel exec -ti deployment.apps/db -- psql --username=creylopez --dbname=jugaralpadel | |||||
| @ -1,20 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| data: | |||||
| DEBUG: "True" | |||||
| ENTORNO: "Pruebas" | |||||
| DJANGO_ALLOWED_HOSTS: "jugaralpadel.ddns.net vmcluster reymota.es k8s-server localhost 127.0.0.1 [::1]" | |||||
| CSRF_TRUSTED_ORIGINS: "https://jugaralpadel.ddns.net http://vmcluster" | |||||
| SECRET_KEY: change_me | |||||
| SQL_DATABASE: jugaralpadel | |||||
| SQL_ENGINE: django.db.backends.postgresql | |||||
| SQL_HOST: db | |||||
| SQL_PASSWORD: Dsa-0213 | |||||
| SQL_PORT: "5432" | |||||
| SQL_USER: creylopez | |||||
| DATABASE: postgres | |||||
| kind: ConfigMap | |||||
| metadata: | |||||
| labels: | |||||
| io.kompose.service: web-env-prod | |||||
| name: env-prod | |||||
| namespace: jugaralpadel | |||||
| @ -1,20 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| data: | |||||
| DEBUG: "False" | |||||
| ENTORNO: "Producción" | |||||
| DJANGO_ALLOWED_HOSTS: "jugaralpadel.ddns.net vmcluster reymota.es k8s-server localhost 127.0.0.1 [::1]" | |||||
| CSRF_TRUSTED_ORIGINS: "https://jugaralpadel.ddns.net http://vmcluster" | |||||
| SECRET_KEY: change_me | |||||
| SQL_DATABASE: jugaralpadel | |||||
| SQL_ENGINE: django.db.backends.postgresql | |||||
| SQL_HOST: db | |||||
| SQL_PASSWORD: Dsa-0213 | |||||
| SQL_PORT: "5432" | |||||
| SQL_USER: creylopez | |||||
| DATABASE: postgres | |||||
| kind: ConfigMap | |||||
| metadata: | |||||
| labels: | |||||
| io.kompose.service: web-env-prod | |||||
| name: env-prod | |||||
| namespace: jugaralpadel | |||||
| @ -1,11 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| data: | |||||
| POSTGRES_DB: jugaralpadel | |||||
| POSTGRES_PASSWORD: Dsa-0213 | |||||
| POSTGRES_USER: creylopez | |||||
| kind: ConfigMap | |||||
| metadata: | |||||
| labels: | |||||
| io.kompose.service: db-env-prod-db | |||||
| name: env-prod-db | |||||
| namespace: jugaralpadel | |||||
| @ -1,134 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: Service | |||||
| metadata: | |||||
| name: jugaralpadel | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| ports: | |||||
| - name: "8000" | |||||
| port: 8000 | |||||
| targetPort: 8000 | |||||
| selector: | |||||
| app: jugaralpadel | |||||
| --- | |||||
| apiVersion: apps/v1 | |||||
| kind: Deployment | |||||
| metadata: | |||||
| name: jugaralpadel | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| replicas: 1 | |||||
| selector: | |||||
| matchLabels: | |||||
| app: jugaralpadel | |||||
| strategy: | |||||
| type: Recreate | |||||
| template: | |||||
| metadata: | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| containers: | |||||
| - args: | |||||
| - gunicorn | |||||
| - gestion_reservas.wsgi:application | |||||
| - --bind | |||||
| - 0.0.0.0:8000 | |||||
| name: jugaralpadel | |||||
| image: $REGISTRY/jugaralpadel-$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 | |||||
| - 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/gestion_reservas/mediafiles | |||||
| name: jugaralpadel-media | |||||
| - mountPath: /app/gestion_reservas/eventos/migrations | |||||
| name: jugaralpadel-eventos-migrations | |||||
| - mountPath: /app/gestion_reservas/reymotausers/migrations | |||||
| name: jugaralpadel-reymotausers-migrations | |||||
| - mountPath: /app/gestion_reservas/staticfiles | |||||
| name: static-volume | |||||
| imagePullSecrets: | |||||
| - name: myregistrykey | |||||
| restartPolicy: Always | |||||
| volumes: | |||||
| - name: jugaralpadel-media | |||||
| persistentVolumeClaim: | |||||
| claimName: jugaralpadel-media | |||||
| - name: jugaralpadel-eventos-migrations | |||||
| persistentVolumeClaim: | |||||
| claimName: jugaralpadel-eventos-migrations | |||||
| - name: jugaralpadel-reymotausers-migrations | |||||
| persistentVolumeClaim: | |||||
| claimName: jugaralpadel-reymotausers-migrations | |||||
| - name: static-volume | |||||
| persistentVolumeClaim: | |||||
| claimName: static-volume | |||||
| status: {} | |||||
| @ -1,50 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| creationTimestamp: null | |||||
| labels: | |||||
| io.kompose.service: jugaralpadel-media | |||||
| name: jugaralpadel-media | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| resources: | |||||
| requests: | |||||
| storage: 100Mi | |||||
| storageClassName: lvms-vg1 | |||||
| status: {} | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| creationTimestamp: null | |||||
| labels: | |||||
| io.kompose.service: jugaralpadel-eventos-migrations | |||||
| name: jugaralpadel-eventos-migrations | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| resources: | |||||
| requests: | |||||
| storage: 50Mi | |||||
| storageClassName: lvms-vg1 | |||||
| status: {} | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| creationTimestamp: null | |||||
| labels: | |||||
| io.kompose.service: jugaralpadel-reymotausers-migrations | |||||
| name: jugaralpadel-reymotausers-migrations | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| resources: | |||||
| requests: | |||||
| storage: 53Mi | |||||
| storageClassName: lvms-vg1 | |||||
| status: {} | |||||
| @ -1,7 +0,0 @@ | |||||
| ################################################### | |||||
| # Namespace Vehículos | |||||
| ################################################### | |||||
| apiVersion: v1 | |||||
| kind: Namespace | |||||
| metadata: | |||||
| name: jugaralpadel | |||||
| @ -1,46 +0,0 @@ | |||||
| 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: jugaralpadel | |||||
| 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-jugaralpadel-$ARQUITECTURA:$IMG_NGINX_VERSION | |||||
| name: nginx | |||||
| ports: | |||||
| - containerPort: 80 | |||||
| protocol: TCP | |||||
| volumeMounts: | |||||
| - mountPath: /app/gestion_reservas/staticfiles | |||||
| name: static-volume | |||||
| - mountPath: /app/gestion_reservas/mediafiles | |||||
| name: jugaralpadel-media | |||||
| imagePullSecrets: | |||||
| - name: myregistrykey | |||||
| restartPolicy: Always | |||||
| volumes: | |||||
| - name: static-volume | |||||
| persistentVolumeClaim: | |||||
| claimName: static-volume | |||||
| - name: jugaralpadel-media | |||||
| persistentVolumeClaim: | |||||
| claimName: jugaralpadel-media | |||||
| @ -1,20 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: Service | |||||
| metadata: | |||||
| annotations: | |||||
| kompose.cmd: kompose convert | |||||
| kompose.version: 1.34.0 (cbf2835db) | |||||
| labels: | |||||
| io.kompose.service: nginx | |||||
| name: nginx | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| type: NodePort | |||||
| ports: | |||||
| - name: "1337" | |||||
| port: 1337 | |||||
| nodePort: 30345 | |||||
| targetPort: 80 | |||||
| selector: | |||||
| io.kompose.service: nginx | |||||
| @ -1,14 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| labels: | |||||
| io.kompose.service: postgres-data | |||||
| name: postgres-data | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| resources: | |||||
| requests: | |||||
| storage: 100Mi | |||||
| storageClassName: lvms-vg1 | |||||
| @ -1,74 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: jugaralpadel-media-folder | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| capacity: | |||||
| storage: 100Mi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/Externo/jugaralpadel/media" | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: jugaralpadel-eventos-migrations-folder | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| capacity: | |||||
| storage: 50Mi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/Externo/jugaralpadel/migrations/eventos" | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: jugaralpadel-reymotausers-migrations-folder | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| capacity: | |||||
| storage: 53Mi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/Externo/jugaralpadel/migrations/reymotausers" | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: jugaralpadel-static-folder | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| capacity: | |||||
| storage: 70Mi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/Externo/jugaralpadel/static" | |||||
| --- | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolume | |||||
| metadata: | |||||
| name: jugaralpadel-pg-folder | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugaralpadel | |||||
| spec: | |||||
| capacity: | |||||
| storage: 200Mi | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| hostPath: | |||||
| path: "/mnt/Externo/jugaralpadel/pg" | |||||
| @ -1,8 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: Secret | |||||
| metadata: | |||||
| name: myregistrykey | |||||
| namespace: jugaralpadel | |||||
| data: | |||||
| .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9 | |||||
| type: kubernetes.io/dockerconfigjson | |||||
| @ -1,14 +0,0 @@ | |||||
| apiVersion: v1 | |||||
| kind: PersistentVolumeClaim | |||||
| metadata: | |||||
| labels: | |||||
| io.kompose.service: static-volume | |||||
| name: static-volume | |||||
| namespace: jugaralpadel | |||||
| spec: | |||||
| accessModes: | |||||
| - ReadWriteOnce | |||||
| resources: | |||||
| requests: | |||||
| storage: 70Mi | |||||
| storageClassName: lvms-vg1 | |||||
| @ -1 +0,0 @@ | |||||
| docker run -it registry.jugaralpadel.es/jugaralpadel-x86_64:0.1 bash | |||||
| @ -1,284 +0,0 @@ | |||||
| kind: Deployment | |||||
| apiVersion: apps/v1 | |||||
| metadata: | |||||
| annotations: | |||||
| alpha.image.policy.openshift.io/resolve-names: '*' | |||||
| app.openshift.io/route-disabled: 'false' | |||||
| app.openshift.io/vcs-ref: '' | |||||
| app.openshift.io/vcs-uri: 'http://gitea.reymota.es/creylopez/JugarAlPadelOC.git' | |||||
| deployment.kubernetes.io/revision: '3' | |||||
| openshift.io/generated-by: OpenShiftWebConsole | |||||
| image.openshift.io/triggers: >- | |||||
| [{"from":{"kind":"ImageStreamTag","name":"jugar-al-padel-oc-git:latest","namespace":"jugaralpadel"},"fieldPath":"spec.template.spec.containers[?(@.name==\"jugar-al-padel-oc-git\")].image","paused":"false"}] | |||||
| resourceVersion: '8774963' | |||||
| name: jugar-al-padel-oc-git | |||||
| uid: b66ba6a9-cb6e-4a8e-ada6-b26843556f75 | |||||
| creationTimestamp: '2025-01-10T18:12:34Z' | |||||
| generation: 3 | |||||
| managedFields: | |||||
| - manager: Mozilla | |||||
| operation: Update | |||||
| apiVersion: apps/v1 | |||||
| time: '2025-01-11T08:52:27Z' | |||||
| fieldsType: FieldsV1 | |||||
| fieldsV1: | |||||
| 'f:metadata': | |||||
| 'f:annotations': | |||||
| .: {} | |||||
| 'f:alpha.image.policy.openshift.io/resolve-names': {} | |||||
| 'f:app.openshift.io/route-disabled': {} | |||||
| 'f:app.openshift.io/vcs-ref': {} | |||||
| 'f:app.openshift.io/vcs-uri': {} | |||||
| 'f:image.openshift.io/triggers': {} | |||||
| 'f:openshift.io/generated-by': {} | |||||
| 'f:labels': | |||||
| .: {} | |||||
| 'f:app': {} | |||||
| 'f:app.kubernetes.io/component': {} | |||||
| 'f:app.kubernetes.io/instance': {} | |||||
| 'f:app.kubernetes.io/name': {} | |||||
| 'f:app.kubernetes.io/part-of': {} | |||||
| 'f:spec': | |||||
| 'f:progressDeadlineSeconds': {} | |||||
| 'f:replicas': {} | |||||
| 'f:revisionHistoryLimit': {} | |||||
| 'f:selector': {} | |||||
| 'f:strategy': | |||||
| 'f:rollingUpdate': | |||||
| .: {} | |||||
| 'f:maxSurge': {} | |||||
| 'f:maxUnavailable': {} | |||||
| 'f:type': {} | |||||
| 'f:template': | |||||
| 'f:metadata': | |||||
| 'f:annotations': | |||||
| .: {} | |||||
| 'f:openshift.openshift.io/restartedAt': {} | |||||
| 'f:labels': | |||||
| .: {} | |||||
| 'f:app': {} | |||||
| 'f:deployment': {} | |||||
| 'f:spec': | |||||
| 'f:containers': | |||||
| 'k:{"name":"jugar-al-padel-oc-git"}': | |||||
| .: {} | |||||
| 'f:env': | |||||
| 'k:{"name":"SQL_USER"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"DEBUG"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| .: {} | |||||
| 'k:{"name":"CSRF_TRUSTED_ORIGINS"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"SQL_DATABASE"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"SQL_PASSWORD"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"DJANGO_ALLOWED_HOSTS"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"SQL_PORT"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"SQL_ENGINE"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"SQL_HOST"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'k:{"name":"DATABASE"}': | |||||
| .: {} | |||||
| 'f:name': {} | |||||
| 'f:valueFrom': | |||||
| .: {} | |||||
| 'f:configMapKeyRef': {} | |||||
| 'f:image': {} | |||||
| 'f:imagePullPolicy': {} | |||||
| 'f:name': {} | |||||
| 'f:resources': {} | |||||
| 'f:terminationMessagePath': {} | |||||
| 'f:terminationMessagePolicy': {} | |||||
| 'f:dnsPolicy': {} | |||||
| 'f:restartPolicy': {} | |||||
| 'f:schedulerName': {} | |||||
| 'f:securityContext': {} | |||||
| 'f:terminationGracePeriodSeconds': {} | |||||
| - manager: kube-controller-manager | |||||
| operation: Update | |||||
| apiVersion: apps/v1 | |||||
| time: '2025-01-11T08:52:28Z' | |||||
| fieldsType: FieldsV1 | |||||
| fieldsV1: | |||||
| 'f:metadata': | |||||
| 'f:annotations': | |||||
| 'f:deployment.kubernetes.io/revision': {} | |||||
| 'f:status': | |||||
| 'f:conditions': | |||||
| .: {} | |||||
| 'k:{"type":"Available"}': | |||||
| .: {} | |||||
| 'f:lastTransitionTime': {} | |||||
| 'f:lastUpdateTime': {} | |||||
| 'f:message': {} | |||||
| 'f:reason': {} | |||||
| 'f:status': {} | |||||
| 'f:type': {} | |||||
| 'k:{"type":"Progressing"}': | |||||
| .: {} | |||||
| 'f:lastTransitionTime': {} | |||||
| 'f:lastUpdateTime': {} | |||||
| 'f:message': {} | |||||
| 'f:reason': {} | |||||
| 'f:status': {} | |||||
| 'f:type': {} | |||||
| 'f:observedGeneration': {} | |||||
| 'f:replicas': {} | |||||
| 'f:unavailableReplicas': {} | |||||
| 'f:updatedReplicas': {} | |||||
| subresource: status | |||||
| namespace: jugaralpadel | |||||
| labels: | |||||
| app: jugar-al-padel-oc-git | |||||
| app.kubernetes.io/component: jugar-al-padel-oc-git | |||||
| app.kubernetes.io/instance: jugar-al-padel-oc-git | |||||
| app.kubernetes.io/name: jugar-al-padel-oc-git | |||||
| app.kubernetes.io/part-of: jugar-al-padel-oc-git-app | |||||
| spec: | |||||
| replicas: 1 | |||||
| selector: | |||||
| matchLabels: | |||||
| app: jugar-al-padel-oc-git | |||||
| template: | |||||
| metadata: | |||||
| creationTimestamp: null | |||||
| labels: | |||||
| app: jugar-al-padel-oc-git | |||||
| deployment: jugar-al-padel-oc-git | |||||
| annotations: | |||||
| openshift.openshift.io/restartedAt: '2025-01-11T08:52:27.178Z' | |||||
| spec: | |||||
| containers: | |||||
| - name: jugar-al-padel-oc-git | |||||
| image: >- | |||||
| image-registry.openshift-image-registry.svc:5000/jugaralpadel/jugar-al-padel-oc-git@sha256:6e3483f13e9f507803385db57ab655d6cb809320f1651968b1a47931a9be2e22 | |||||
| env: | |||||
| - name: DEBUG | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DEBUG | |||||
| - name: DJANGO_ALLOWED_HOSTS | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DJANGO_ALLOWED_HOSTS | |||||
| - name: CSRF_TRUSTED_ORIGINS | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: CSRF_TRUSTED_ORIGINS | |||||
| - name: DATABASE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DATABASE | |||||
| - name: SQL_HOST | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_HOST | |||||
| - name: SQL_PORT | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_PORT | |||||
| - name: SQL_ENGINE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_ENGINE | |||||
| - name: SQL_DATABASE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_DATABASE | |||||
| - name: SQL_USER | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_USER | |||||
| - name: SQL_PASSWORD | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_PASSWORD | |||||
| resources: {} | |||||
| terminationMessagePath: /dev/termination-log | |||||
| terminationMessagePolicy: File | |||||
| imagePullPolicy: Always | |||||
| restartPolicy: Always | |||||
| terminationGracePeriodSeconds: 30 | |||||
| dnsPolicy: ClusterFirst | |||||
| securityContext: {} | |||||
| schedulerName: default-scheduler | |||||
| imagePullSecrets: [] | |||||
| strategy: | |||||
| type: RollingUpdate | |||||
| rollingUpdate: | |||||
| maxSurge: 25% | |||||
| maxUnavailable: 25% | |||||
| revisionHistoryLimit: 10 | |||||
| progressDeadlineSeconds: 600 | |||||
| paused: false | |||||
| status: | |||||
| observedGeneration: 3 | |||||
| replicas: 1 | |||||
| updatedReplicas: 1 | |||||
| unavailableReplicas: 1 | |||||
| conditions: | |||||
| - type: Progressing | |||||
| status: 'True' | |||||
| lastUpdateTime: '2025-01-11T08:52:28Z' | |||||
| lastTransitionTime: '2025-01-10T18:12:34Z' | |||||
| reason: NewReplicaSetAvailable | |||||
| message: >- | |||||
| ReplicaSet "jugar-al-padel-oc-git-7bc989c94d" has successfully | |||||
| progressed. | |||||
| - type: Available | |||||
| status: 'False' | |||||
| lastUpdateTime: '2025-01-11T08:52:28Z' | |||||
| lastTransitionTime: '2025-01-11T08:52:28Z' | |||||
| reason: MinimumReplicasUnavailable | |||||
| message: Deployment does not have minimum availability. | |||||
| @ -1,51 +0,0 @@ | |||||
| env: | |||||
| - name: DEBUG | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DEBUG | |||||
| - name: DJANGO_ALLOWED_HOSTS | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DJANGO_ALLOWED_HOSTS | |||||
| - name: CSRF_TRUSTED_ORIGINS | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: CSRF_TRUSTED_ORIGINS | |||||
| - name: DATABASE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: DATABASE | |||||
| - name: SQL_HOST | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_HOST | |||||
| - name: SQL_PORT | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_PORT | |||||
| - name: SQL_ENGINE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_ENGINE | |||||
| - name: SQL_DATABASE | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_DATABASE | |||||
| - name: SQL_USER | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_USER | |||||
| - name: SQL_PASSWORD | |||||
| valueFrom: | |||||
| configMapKeyRef: | |||||
| name: env-prod | |||||
| key: SQL_PASSWORD | |||||
| @ -1,20 +0,0 @@ | |||||
| #!/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,4 +0,0 @@ | |||||
| FROM nginx:1.25 | |||||
| RUN rm /etc/nginx/conf.d/default.conf | |||||
| COPY nginx.conf /etc/nginx/conf.d | |||||
| @ -1,8 +0,0 @@ | |||||
| install: | |||||
| echo "Creando imagen con version '${IMG_NGINX_VERSION}' para la arquitectura '${ARQUITECTURA}' en el registry '${REGISTRY}'" | |||||
| docker build --no-cache -t ${REGISTRY}/nginx-jugaralpadel-${ARQUITECTURA}:${IMG_NGINX_VERSION} . | |||||
| docker push ${REGISTRY}/nginx-jugaralpadel-${ARQUITECTURA}:${IMG_NGINX_VERSION} | |||||
| @ -0,0 +1,32 @@ | |||||
| upstream django_project { | |||||
| server localhost:8000; | |||||
| } | |||||
| error_log /var/log/nginx/error.log; | |||||
| server { | |||||
| listen 80; | |||||
| server_name reymota.lab *.reymota.lab; | |||||
| access_log /var/log/nginx/access.log; | |||||
| location / { | |||||
| proxy_pass http://django_project; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_set_header Host $host; | |||||
| proxy_redirect off; | |||||
| client_max_body_size 100M; | |||||
| } | |||||
| location /static/ { | |||||
| alias /app/wsgi/static/; | |||||
| } | |||||
| location /media/ { | |||||
| alias /app/wsgi/mediafiles/; | |||||
| } | |||||
| error_page 500 502 503 504 /50x.html; | |||||
| location = /50x.html { | |||||
| root /usr/share/nginx/html; | |||||
| } | |||||
| } | |||||
| @ -1,25 +0,0 @@ | |||||
| upstream jugaralpadel { | |||||
| server jugaralpadel:8000; | |||||
| } | |||||
| server { | |||||
| listen 80; | |||||
| location / { | |||||
| proxy_pass http://jugaralpadel; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_set_header Host $http_host; | |||||
| proxy_redirect off; | |||||
| client_max_body_size 100M; | |||||
| } | |||||
| location /static/ { | |||||
| alias /app/gestion_reservas/staticfiles/; | |||||
| } | |||||
| location /media/ { | |||||
| alias /app/gestion_reservas/mediafiles/; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,23 @@ | |||||
| #!/bin/bash | |||||
| RUN_PORT="8000" | |||||
| SQL_HOST=5432 | |||||
| if [ "$DATABASE" = "postgres" ] | |||||
| then | |||||
| echo "Waiting for postgres..." | |||||
| while ! nc -z $SQL_HOST $SQL_PORT; do | |||||
| sleep 0.1 | |||||
| done | |||||
| echo "PostgreSQL started" | |||||
| /opt/venv/bin/python manage.py migrate --no-input | |||||
| /opt/venv/bin/python manage.py collectstatic --no-input | |||||
| /opt/venv/bin/gunicorn gestion_reservas.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon | |||||
| nginx -g 'daemon off;' | |||||
| else | |||||
| echo "la base de datos no es postgres: '$DATABASE'" | |||||
| fi | |||||