Skip to content

Commit

Permalink
Merge pull request #2 from jaguar-ks/main
Browse files Browse the repository at this point in the history
restore main
  • Loading branch information
jaguar-ks authored Nov 13, 2024
2 parents 1fcc6e4 + 293d8ec commit 1026ca0
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 431 deletions.
30 changes: 9 additions & 21 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
SECRET_KEY='django-insecure-(fffc75h_s6tm=%7a&r8vc2lf7*0q+w2k+=*g=@82nube9s*a-'
DEBUG=True
# postgres credentials

FORTYTWO_CLIENT_ID='u-s4t2ud-ab8fff39c8779f781296f279fd71d49a1ae34cb59003ad44bb0dc94d475ceffc'
FORTYTWO_CLIENT_SECRET='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'
FORTYTWO_REDIRECT_URI='http://localhost:4444'
POSTGRES_PASSWORD='postgres_password'
POSTGRES_DB='postgres_db'
POSTGRES_USER='postgres_user'

# google social_auth
GOOGLE_CLIENT_ID='GOOGLE_CLIENT_ID'
GOOGLE_REDIRECT_URI='GOOGLE_REDIRECT_URI'


# github social_auth
GITHUB_CLIENT_ID='GITHUB_CLIENT_ID'
GITHUB_REDIRECT_URI='GITHUB_REDIRECT_URI'

POSTGRES_USER="postgres"
POSTGRES_PASSWORD="A9wadPassW0rd/"
POSTGRES_DB="db"
DATABASE_URL="postgres://postgres:A9wadPassW0rd/@db:5432/db"

LOGSTASH_HOST="logstash"
LOGSTASH_PORT="50000"
# django superuser credentials
DJANGO_SECRET_KEY='django_secret_key'
DJANGO_SUPERUSER_USERNAME='django_admin_user'
DJANGO_SUPERUSER_EMAIL='django_admin_email'
DJANGO_SUPERUSER_PASSWORD='django_admin_password'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ htmlcov/
# Migrations
**/migrations/*
!**/migrations/__init__.py
*todo*
todo*
91 changes: 0 additions & 91 deletions ELK/docker-compose.yml

This file was deleted.

8 changes: 0 additions & 8 deletions ELK/elasticsearch/config/elasticsearch.yml

This file was deleted.

7 changes: 0 additions & 7 deletions ELK/kibana/config/kibana.yml

This file was deleted.

5 changes: 0 additions & 5 deletions ELK/logstash/config/logstash.yml

This file was deleted.

36 changes: 0 additions & 36 deletions ELK/logstash/pipeline/logstash.conf

This file was deleted.

16 changes: 0 additions & 16 deletions ELK/tools/init-kibana.sh

This file was deleted.

23 changes: 4 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
images=$(shell docker image ls -aq)

elk_net=$(shell docker network ls -qf name="elk_net")

all: build

create_net:
if [ -n "$(elk_net)" ];\
then echo "Network elk_net already exists";\
else\
docker network create elk_net;\
fi

build: create_net
build:
docker-compose -f docker-compose.yml build

up: build
Expand All @@ -20,22 +11,16 @@ up: build
down:
docker-compose -f docker-compose.yml down

ELK: create_net
docker-compose -f ./ELK/docker-compose.yml up

ELK_down:
docker-compose -f ./ELK/docker-compose.yml down

delete_images:
if [ -n "$(images)" ];\
then docker rmi $(images);\
else\
echo "No images to delete";\
fi

fclean: down ELK_down delete_images
fclean: down delete_images
docker system prune -a --force

.PHONY: all build up down delete_images fclean ELK ELK_down create_net
.PHONY: all build up down delete_images fclean

.SILENT: all build up down delete_images fclean create_net ELK ELK_down
.SILENT: all build up down delete_images fclean
45 changes: 13 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ services:
networks:
- transcendance_net
restart: always
env_file:
- .env.example
# environment:
# POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
# POSTGRES_DB: ${POSTGRES_DB}
# POSTGRES_USER: ${POSTGRES_USER}
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}


backend:
Expand All @@ -23,37 +21,23 @@ services:
build:
context: ./srcs/api/
volumes:
- ./srcs/api/:/var/www/
- backend_files:/var/www/
networks:
- transcendance_net
- elk_net
ports:
- 8000:8000
depends_on:
- pgdb
env_file:
- .env.example
restart: on-failure
# environment:
# DEBUG: True # ['True', 'False']
# DJANGO_SETTING_MODULE: config.django.local
# DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pgdb:5432/${POSTGRES_DB}
# DJANGO_SUPERUSER_USERNAME: ${DJANGO_SUPERUSER_USERNAME}
# DJANGO_SUPERUSER_EMAIL: ${DJANGO_SUPERUSER_EMAIL}
# DJANGO_SUPERUSER_PASSWORD: ${DJANGO_SUPERUSER_PASSWORD}
environment:
DEBUG: True # ['True', 'False']
DJANGO_SETTING_MODULE: config.django.local
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pgdb:5432/${POSTGRES_DB}
DJANGO_SUPERUSER_USERNAME: ${DJANGO_SUPERUSER_USERNAME}
DJANGO_SUPERUSER_EMAIL: ${DJANGO_SUPERUSER_EMAIL}
DJANGO_SUPERUSER_PASSWORD: ${DJANGO_SUPERUSER_PASSWORD}
DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY}

frontend:
build: ./srcs/frontend
container_name: nextJs
ports:
- "3000:3000" # Map host port 3000 to container port 3000
volumes:
- ./srcs/frontend/src/:/app/src/
depends_on:
- backend
networks:
- transcendance_net
restart: on-failure

volumes:
postgres_data:
Expand All @@ -66,6 +50,3 @@ volumes:

networks:
transcendance_net:
elk_net:
external: true
name: elk_net
3 changes: 0 additions & 3 deletions srcs/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
db.sqlite3
*__pycache__/
*.pyc
2 changes: 1 addition & 1 deletion srcs/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-slim-bullseye
FROM python:3.11-slim-bullseye

# Set the working directory in the container
WORKDIR /var/www/
Expand Down
4 changes: 1 addition & 3 deletions srcs/api/apps/users/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from rest_framework import generics, filters
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.permissions import AllowAny
from .models import User
from rest_framework.response import Response

from . import serializers

class AuthUserView(generics.RetrieveUpdateDestroyAPIView):

permission_classes = [IsAuthenticated]

def get_serializer_class(self):
if self.request.method in ['PUT', 'PATCH']:
return serializers.UpdateAuthUserSerializer
Expand Down
3 changes: 0 additions & 3 deletions srcs/api/apps/utils/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.contrib.auth import get_user_model
from rest_framework import serializers
import re
from django.contrib.auth import get_user_model

User = get_user_model()

Expand Down Expand Up @@ -47,8 +46,6 @@ def __call__(self, value):
if any(bad in value for bad in ["__", "--", "_-", "-_"]):
errors.append("Username cannot contain consecutive special characters like '__', '_-', or similar.")
reserved_usernames = ['admin', 'root', 'superuser']
if get_user_model().objects.filter(username=value).exists():
errors.append("A user with that username already exists.")
if value.lower() in reserved_usernames:
errors.append("This username is reserved and cannot be used.")
if errors:
Expand Down
Loading

0 comments on commit 1026ca0

Please sign in to comment.