From 4016a2dc1372c6ffd197fa7313d2ad41416337d9 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Wed, 12 Feb 2025 15:54:35 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1ado=20rsync=20para=20poder=20copiar=20fi?= =?UTF-8?q?cheros=20al=20contenedor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 40 ++++++++++++++++++++++++++ README.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bff326b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# yup, python 3.11! +FROM python:3.11-slim + +<<<<<<< HEAD +# install nginx +RUN apt-get update && apt-get install nginx netcat-openbsd rsync -y +======= +# install nginx y otras cosas +RUN apt-get update && apt-get install nginx netcat-openbsd curl vim jq -y +>>>>>>> c04abab64cc16d19cf44b2b6e95eb68cccfb37b5 +# copy our nginx configuration to overwrite nginx defaults +RUN rm /etc/nginx/sites-enabled/default +RUN rm /etc/nginx/sites-available/default +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 + +# copy the django code +COPY ./src ./app + +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 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 + +# make our entrypoint.sh executable +RUN chmod +x config/entrypoint.sh + +EXPOSE 80 + +# execute our entrypoint.sh file +CMD ["./config/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..a193dab --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# Versión para openshift + +## permitir a nginx correr con privilegios + +### esto se hace una vez dentro del proyecto. + +oc adm policy add-scc-to-user -z default anyuid + +## Instalación + +Crear un proyecto y luego añadir una app desde Agregar, importar desde git. + +Tal y como está la estructura de directorios, deberia detectar automáticamente una compilación Python + + +Desde la línea de comandos, sería: + +oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG=True + + + + + + +python manage.py createsuperuser + + +python manage.py makemigrations + +python manage.py migrate + +## Comprobar la base de datos + +Con la shell entraPsql.sh: + +\l para listar las BD + +\c reymota para usar nuestra db +\dt para ver las tablas + +# De dónde cogí ideas + +https://learndjango.com/tutorials/django-login-and-logout-tutorial + + +Username: {{ user.username }} + +User Full name: {{ user.get_full_name }} + +User Group: {{ user.groups.all.0 }} + +Email: {{ user.email }} + +Session Started at: {{ user.last_login }} + + +## Para funcionar con gunicorn y nginx +https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/ + + + +## Cambiar la secuencia de lo sid + +ALTER SEQUENCE tablename_id_seq RESTART WITH nn; + +esto se hace cuando restauro un volcado de la bd sobre una instalación nueva. Si hay índices ya creados, hay que reinciar a partir del último. + +<<<<<<< HEAD +## Copiar ficheros al contenedor + +Copy local directory to a pod directory +oc rsync /home/user/source devpod1234:/src + +# Copy pod directory to a local directory +oc rsync devpod1234:/src /home/user/source +======= +## Para que git no pida credenciales + +git config --global credential.helper store + + +la siguiente vez que se haga el push nos la pedirá una última vez + +>>>>>>> c04abab64cc16d19cf44b2b6e95eb68cccfb37b5