Skip to content

Commit

Permalink
Merge pull request #220 from fleizean/spa
Browse files Browse the repository at this point in the history
Spa
  • Loading branch information
yeaktas authored Apr 17, 2024
2 parents 0a8148c + 47de012 commit d8a3bd8
Show file tree
Hide file tree
Showing 26 changed files with 145 additions and 229 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zort
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local_settings.py
db.sqlite3
db.sqlite3-journal
media
staticfiles
migrations/
0001_initial.py

Expand Down
23 changes: 0 additions & 23 deletions Deploy/.envtemplate

This file was deleted.

11 changes: 0 additions & 11 deletions Deploy/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions Deploy/Dockerfile.nginx

This file was deleted.

39 changes: 0 additions & 39 deletions Deploy/docker-compose.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions Deploy/structure.txt

This file was deleted.

22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerfile
FROM python:3.11.4-slim-buster

ENV PIP_ROOT_USER_ACTION=ignore \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
#PIP_NO_CACHE_DIR=off


WORKDIR /ft_transcendence

COPY indianpong /ft_transcendence/

RUN pip install --upgrade pip && pip install -r requirements.txt

RUN chmod +x start.sh

EXPOSE 8001

CMD [ "bash", "start.sh" ]


17 changes: 17 additions & 0 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM nginx

# Create a directory for the certificates
RUN mkdir -p /ssl_data && mkdir -p /etc/nginx/ssl

# Generate a self-signed certificate
RUN openssl req -x509 -newkey rsa:4096 -keyout /ssl_data/key.pem -out /ssl_data/cert.pem -days 365 -nodes -subj '/CN=localhost'

# Copy the certificates to the Nginx directory
RUN cp /ssl_data/key.pem /etc/nginx/ssl/key.pem && cp /ssl_data/cert.pem /etc/nginx/ssl/cert.pem

# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf

# Expose the Nginx port
EXPOSE 8000
EXPOSE 8443
45 changes: 45 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# docker-compose.yaml
version: '3.9'

services:
db:
image: postgres:13
restart: always
ports:
- "5432:5432"
env_file:
- .env

web:
build:
context: .
dockerfile: Dockerfile
volumes:
- staticfiles:/ft_transcendence/staticfiles
- media:/ft_transcendence/media
- ssl_data:/ssl_data
env_file:
- .env
ports:
- 8001:8001
depends_on:
- db

nginx:
build:
context: .
dockerfile: Dockerfile.nginx
volumes:
- staticfiles:/ft_transcendence/staticfiles
- media:/ft_transcendence/media
- ssl_data:/ssl_data
ports:
- 8000:8000
- 8443:8443
depends_on:
- web

volumes:
staticfiles:
media:
ssl_data:
30 changes: 0 additions & 30 deletions docker-compose.yml

This file was deleted.

15 changes: 0 additions & 15 deletions docker.dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions indianpong/Dockerfile

This file was deleted.

33 changes: 21 additions & 12 deletions indianpong/indianpong/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@
SECRET_KEY = environ.get("SECRET_KEY", default="w^bxst+y6yv=d*5+7h)2s3)5vfz!b2jayit+#1epn(gr1-fotw")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = environ.get("DEBUG", default=True)
DEBUG = environ.get("DEBUG", default=False)

BASE_URL = environ.get("BASE_URL", default="http://localhost:8000")
BASE_URL = environ.get("BASE_URL", default='https://localhost:8443')

ALLOWED_HOSTS = ['indianpong.com','indianpong.onrender.com', 'http://127.0.0.1:8000', 'localhost', '127.0.0.1']#environ.get("ALLOWED_HOSTS", default="").split(" ")
ALLOWED_HOSTS = ['indianpong.com','indianpong.onrender.com', 'http://127.0.0.1:8000', 'localhost', '127.0.0.1', 'https://127.0.0.1:8443', 'https://localhost:8443']#environ.get("ALLOWED_HOSTS", default="").split(" ")

CSRF_TRUSTED_ORIGINS = [
'https://indianpong.onrender.com',
'http://indianpong.onrender.com',
'https://127.0.0.1:8443',
'https://localhost:8443',
'http://localhost:8000',
'http://127.0.0.1:8000',
]

# Eğer Django versiyonunuz 3.1 veya üzeriyse aşağıdaki ayarı da ekleyin
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True

# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -101,8 +109,8 @@

# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
"""
DATABASES = {

""" DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
Expand All @@ -112,12 +120,12 @@

DATABASES = {
'default': {
'ENGINE': os.getenv('DB_ENGINE', default='django.db.backends.postgresql'),
'NAME': os.getenv('DB_NAME', default='pong'),
'USER': os.getenv('DB_USER', default='indianpong'),
'PASSWORD': os.getenv('DB_PASSWORD', default='indianpong123'),
'HOST': 'db', # Değişiklik burada
'PORT': os.getenv('DB_PORT', default='5432'),
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('POSTGRES_DB', default='pong'),
'USER': os.getenv('POSTGRES_USER', default='indianpong'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD', default='indianpong123'),
'HOST': 'db',
'PORT': '5432',
}
}

Expand Down Expand Up @@ -171,7 +179,8 @@
BASE_DIR / 'static',
]

STATIC_ROOT = path.join(BASE_DIR, 'staticfiles')
""" STATIC_ROOT = path.join(BASE_DIR, 'staticfiles') """
STATIC_ROOT = '/ft_transcendence/staticfiles'

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
Expand Down
3 changes: 2 additions & 1 deletion indianpong/pong/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta
from email.mime.image import MIMEImage
import os
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.core.mail import send_mail
from django import forms
Expand Down Expand Up @@ -529,7 +530,7 @@ def save(self, domain_override=None, token_generator=default_token_generator, re
mail_subject = 'Reset your password'
message = render_to_string('password_reset_email.html', {
'user': user,
'domain': domain_override or request.META['HTTP_HOST'],
'domain': settings.BASE_URL,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': token,
})
Expand Down
1 change: 1 addition & 0 deletions indianpong/pong/management/commands/initdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def handle(self, *args, **options):
super_user.avatar.save(f"{file.name}.jpg", file, save=False)
file.close()
super_user.indian_wallet = 1000
super_user.is_verified = True
super_user.save()
self.stdout.write(self.style.SUCCESS('Superuser created successfully.'))
# Create IndianAI if not exists
Expand Down
3 changes: 2 additions & 1 deletion indianpong/pong/management/commands/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def handle(self, *args, **options):
displayname=displayname,
password=password,
game_stats_pong=game_stat,
social=social
social=social,
is_verified=True
)
user_profiles.append(user_profile)

Expand Down
Loading

0 comments on commit d8a3bd8

Please sign in to comment.