Skip to content

Commit

Permalink
Merge pull request #225 from fleizean/spa
Browse files Browse the repository at this point in the history
Spa
  • Loading branch information
temasictfic committed Apr 18, 2024
2 parents 256077e + 06bf6e1 commit 2041aac
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ ENV PIP_ROOT_USER_ACTION=ignore \
#PIP_NO_CACHE_DIR=off


WORKDIR /ft_transcendence
COPY indianpong /indianpong

COPY indianpong /ft_transcendence/
RUN pip install --upgrade pip && pip install -r /indianpong/requirements.txt

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

RUN chmod +x start.sh
RUN chmod +x /indianpong/start.sh

EXPOSE 8001

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


7 changes: 2 additions & 5 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM nginx

# Create a directory for the certificates
RUN mkdir -p /ssl_data && mkdir -p /etc/nginx/ssl
RUN 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
RUN openssl req -x509 -newkey rsa:4096 -keyout /etc/nginx/ssl/key.pem -out /etc/nginx/ssl/cert.pem -days 365 -nodes -subj '/CN=localhost'

# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- staticfiles:/ft_transcendence/staticfiles
- media:/ft_transcendence/media
- ssl_data:/ssl_data
- staticfiles:/indianpong/staticfiles
- media:/indianpong/media
- ssl_data:/etc/nginx/ssl
env_file:
- .env
ports:
Expand All @@ -30,9 +30,9 @@ services:
context: .
dockerfile: Dockerfile.nginx
volumes:
- staticfiles:/ft_transcendence/staticfiles
- media:/ft_transcendence/media
- ssl_data:/ssl_data
- staticfiles:/indianpong/staticfiles
- media:/indianpong/media
- ssl_data:/etc/nginx/ssl
ports:
- 8000:8000
- 8443:8443
Expand Down
4 changes: 2 additions & 2 deletions indianpong/indianpong/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
BASE_DIR / 'static',
]

""" STATIC_ROOT = path.join(BASE_DIR, 'staticfiles') """
STATIC_ROOT = '/ft_transcendence/staticfiles'
STATIC_ROOT = 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
2 changes: 1 addition & 1 deletion indianpong/pong/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.test import TestCase

# Create your tests here.
# FILEPATH: /home/gusto/ft_transcendence_newpdf/indianpong/indianpong/tests.py
# FILEPATH: /home/gusto/ft_transcendence/indianpong/indianpong/tests.py
import pytest
from channels.testing import WebsocketCommunicator
from django.test import TestCase
Expand Down
2 changes: 1 addition & 1 deletion indianpong/pong/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def auth_callback(request):
ssl_context = ssl.create_default_context()

# Load your certificate
ssl_context.load_cert_chain(certfile='../ssl_data/cert.pem', keyfile='../ssl_data/key.pem')
ssl_context.load_cert_chain(certfile='../etc/nginx/ssl/cert.pem', keyfile='../etc/nginx/ssl/key.pem')
#ssl_context = ssl._create_unverified_context() # TODO temporary solution
code = request.GET.get("code")
data = {
Expand Down
5 changes: 3 additions & 2 deletions indianpong/start.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

python3 manage.py makemigrations
cd indianpong
python3 manage.py makemigrations pong
python3 manage.py migrate
python3 manage.py initdata
python3 manage.py populate 10
python3 manage.py collectstatic --no-input
echo "Starting Daphne server..."
daphne -b 0.0.0.0 -p 8001 -e ssl:8443:privateKey=/ssl_data/key.pem:certKey=/ssl_data/cert.pem indianpong.asgi:application
daphne -b 0.0.0.0 -p 8001 -e ssl:8443:privateKey=/etc/nginx/ssl/key.pem:certKey=/etc/nginx/ssl/cert.pem indianpong.asgi:application
echo "Daphne server started"
4 changes: 2 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ http {
ssl_certificate_key /etc/nginx/ssl/key.pem;

location /static/ {
alias /ft_transcendence/staticfiles/;
alias /indianpong/staticfiles/;
}

location /media/ {
alias /ft_transcendence/media/;
alias /indianpong/media/;
}

location /ws/ {
Expand Down

0 comments on commit 2041aac

Please sign in to comment.