Browse Source

Añado rsync para poder copiar ficheros al contenedor

main
Celestino Rey 9 months ago
parent
commit
4016a2dc13
2 changed files with 124 additions and 0 deletions
  1. +40
    -0
      Dockerfile
  2. +84
    -0
      README.md

+ 40
- 0
Dockerfile View File

@ -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"]

+ 84
- 0
README.md View File

@ -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

Loading…
Cancel
Save