| @ -1,33 +0,0 @@ | |||||
| # yup, python 3.11! | |||||
| FROM python:3.11-slim | |||||
| # install nginx | |||||
| RUN apt-get update && apt-get install nginx netcat-openbsd rsync -y | |||||
| # 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 | |||||
| # execute our entrypoint.sh file | |||||
| CMD ["./config/entrypoint.sh"] | |||||
| @ -1,69 +0,0 @@ | |||||
| # Versión para openshift | |||||
| ## ATENCIÓN | |||||
| Creo que el Dockerfile que hay en el directorio raíz no sirve para nada. | |||||
| ## 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 | |||||
| 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. | |||||
| ## 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 | |||||
| @ -0,0 +1 @@ | |||||
| oc exec -it deployment.apps/reymotaappsoc -- bash | |||||
| @ -0,0 +1 @@ | |||||
| oc new-app http://gitea.reymota.es/creylopez/ReyMotaAppsOC.git -e DEBUG=True | |||||
| @ -0,0 +1,67 @@ | |||||
| 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 | |||||
| storageClassName: lvms-vg1 | |||||
| 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 | |||||
| storageClassName: lvms-vg1 | |||||
| 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 | |||||
| storageClassName: lvms-vg1 | |||||
| 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 | |||||
| storageClassName: lvms-vg1 | |||||
| status: {} | |||||
| @ -1,52 +0,0 @@ | |||||
| # Generated by Django 4.2 on 2024-09-10 13:23 | |||||
| import django.core.validators | |||||
| from django.db import migrations, models | |||||
| import django.db.models.deletion | |||||
| import lyrics.models | |||||
| class Migration(migrations.Migration): | |||||
| initial = True | |||||
| dependencies = [ | |||||
| ] | |||||
| operations = [ | |||||
| migrations.CreateModel( | |||||
| name='Album', | |||||
| fields=[ | |||||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |||||
| ('name', models.CharField(max_length=200)), | |||||
| ('year', models.PositiveBigIntegerField(default=2024, validators=[django.core.validators.MinValueValidator(1984), lyrics.models.max_value_current_year])), | |||||
| ('cover_image', models.ImageField(blank=True, null=True, upload_to='cover_image/')), | |||||
| ], | |||||
| ), | |||||
| migrations.CreateModel( | |||||
| name='Artista', | |||||
| fields=[ | |||||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |||||
| ('nombre', models.CharField(max_length=200)), | |||||
| ('biografia', models.TextField(blank=True, null=True)), | |||||
| ('foto', models.ImageField(blank=True, null=True, upload_to='artistas/')), | |||||
| ], | |||||
| ), | |||||
| migrations.CreateModel( | |||||
| name='Song', | |||||
| fields=[ | |||||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |||||
| ('title', models.CharField(max_length=200)), | |||||
| ('year', models.PositiveBigIntegerField(default=2024, validators=[django.core.validators.MinValueValidator(1984), lyrics.models.max_value_current_year])), | |||||
| ('lyrics', models.CharField(max_length=1000)), | |||||
| ('pista', models.DecimalField(blank=True, decimal_places=0, max_digits=5, null=True)), | |||||
| ('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lyrics.album')), | |||||
| ('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lyrics.artista')), | |||||
| ], | |||||
| ), | |||||
| migrations.AddField( | |||||
| model_name='album', | |||||
| name='artist', | |||||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lyrics.artista'), | |||||
| ), | |||||
| ] | |||||
| @ -1,14 +1,20 @@ | |||||
| asgiref==3.8.1 | asgiref==3.8.1 | ||||
| Django==4.2 | Django==4.2 | ||||
| django-calculation==1.0.0 | |||||
| djangorestframework==3.15.2 | |||||
| flake8==7.1.1 | flake8==7.1.1 | ||||
| gunicorn==22.0.0 | gunicorn==22.0.0 | ||||
| mccabe==0.7.0 | mccabe==0.7.0 | ||||
| numpy==2.2.2 | |||||
| packaging==24.1 | packaging==24.1 | ||||
| pandas==2.2.3 | |||||
| pillow==10.4.0 | pillow==10.4.0 | ||||
| psycopg2-binary==2.9.6 | psycopg2-binary==2.9.6 | ||||
| pycodestyle==2.12.1 | pycodestyle==2.12.1 | ||||
| pyflakes==3.2.0 | pyflakes==3.2.0 | ||||
| python-dateutil==2.9.0.post0 | |||||
| pytz==2025.1 | |||||
| six==1.17.0 | |||||
| sqlparse==0.5.1 | sqlparse==0.5.1 | ||||
| typing_extensions==4.12.2 | typing_extensions==4.12.2 | ||||
| django-calculation==1.0.0 | |||||
| pandas==2.2.3 | |||||
| tzdata==2025.1 | |||||
| @ -1,34 +0,0 @@ | |||||
| # Generated by Django 4.2 on 2024-09-03 14:49 | |||||
| from django.db import migrations, models | |||||
| class Migration(migrations.Migration): | |||||
| initial = True | |||||
| dependencies = [ | |||||
| ('auth', '0012_alter_user_first_name_max_length'), | |||||
| ] | |||||
| operations = [ | |||||
| migrations.CreateModel( | |||||
| name='ReyMotaUser', | |||||
| fields=[ | |||||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |||||
| ('password', models.CharField(max_length=128, verbose_name='password')), | |||||
| ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), | |||||
| ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), | |||||
| ('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')), | |||||
| ('foto', models.ImageField(blank=True, default='profile_images/default.jpg', upload_to='profile_images')), | |||||
| ('is_staff', models.BooleanField(default=False)), | |||||
| ('is_active', models.BooleanField(default=True)), | |||||
| ('nombre', models.CharField(blank=True, max_length=200, null=True)), | |||||
| ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), | |||||
| ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), | |||||
| ], | |||||
| options={ | |||||
| 'abstract': False, | |||||
| }, | |||||
| ), | |||||
| ] | |||||