Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
cris96spa committed Oct 28, 2024
1 parent 4d162e4 commit d41be03
Show file tree
Hide file tree
Showing 192 changed files with 57,861 additions and 1,066 deletions.
13 changes: 12 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
fly.toml
.git/
venv/
__pycache__/
.github/
.gitignore
.hooks/
.pytest_cache/
.__pycache__
.ruff_cache
.uv_cache
.vscode/
.test/
.pytest_cache/
3 changes: 3 additions & 0 deletions .ebextensions/django.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: portfolio.wsgi:application
7 changes: 7 additions & 0 deletions .ebextensions/launch-template.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resources:
AWSEBAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
LaunchTemplate:
LaunchTemplateId: "lt-05d56f3471ff59142"
Version: "$Latest"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ cython_debug/
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
.dockerignore
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ ARG PYTHON_VERSION=3.12-slim

FROM python:${PYTHON_VERSION}

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PROD=1

# install psycopg2 dependencies.
RUN apt-get update && apt-get install -y \
Expand All @@ -21,14 +22,11 @@ RUN pip install poetry
COPY ./pyproject.toml ./pyproject.toml
RUN uv pip compile pyproject.toml --extra dev -o requirements.txt --extra-index-url https://pypi.org/simple/ --no-cache
RUN pip install -r requirements.txt --extra-index-url https://pypi.org/simple/ --no-cache
COPY . /app

ENV SECRET_KEY "mMV6vgXTs9qs3flESOrCkA0WDwgO96rWtnoTKqiaRAJug9u5qU"
COPY . /app/

EXPOSE 8000
RUN python manage.py collectstatic --noinput
RUN python manage.py makemigrations
RUN python manage.py migrate
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# CMD ["gunicorn", "--bind", "0.0.0.0:8000", "portfolio.wsgi:application"]

# CMD "gunicorn", "--bind", "127.0.0.1:8000", "portfolio.wsgi:application"]
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,13 @@ docker-tag:
docker-push:
docker push portfolio:$(BRANCH_NAME)

docker-setup: docker-build docker-tag docker-run
docker-setup: docker-build docker-tag docker-run

# === DEPLOYMENT DOCKER COMPOSE
docker-compose-build:
docker-compose build

docker-compose-up:
docker-compose up

docker-compose-setup: docker-compose-build docker-compose-up
11 changes: 8 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
version: "3.12"

services:
web:
image: portfolio
build: .
ports:
- "8000:8000"
command: gunicorn --bind 0.0.0.0:8000 portfolio.wsgi:application
volumes:
- .:/app
expose:
- "8000"
env_file:
- .env
environment:
DJANGO_SETTINGS_MODULE: portfolio.settings
33 changes: 0 additions & 33 deletions fly.toml

This file was deleted.

5 changes: 2 additions & 3 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

# Register your models here.
from django.contrib import admin
from .models import Project, Category, Contact, SkillCategory, Skill
from .models import Project, Category, SkillCategory, Skill

admin.site.register(Category)
admin.site.register(Project)
admin.site.register(Contact)
admin.site.register(SkillCategory)
admin.site.register(Skill)
admin.site.register(Skill)
11 changes: 0 additions & 11 deletions home/middleware.py

This file was deleted.

16 changes: 16 additions & 0 deletions home/migrations/0011_delete_contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.1.2 on 2024-10-25 20:46

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('home', '0010_remove_project_technologies_used'),
]

operations = [
migrations.DeleteModel(
name='Contact',
),
]
87 changes: 51 additions & 36 deletions home/models.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
from django.db import models
from django.db.models import (
Model,
CharField,
TextField,
URLField,
ForeignKey,
ManyToManyField,
IntegerField,
AutoField,
CASCADE,
)
from django.core.validators import MinValueValidator, MaxValueValidator

# Create your models here.

class Category(models.Model):
name = models.CharField(max_length=100)
tag = models.CharField(max_length=100)
rank = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(10)])
def __str__(self):
return self.name

class Project(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=200)
short_description = models.CharField(max_length=300)
description = models.TextField()
category = models.ForeignKey(Category, on_delete=models.CASCADE)
github_link = models.URLField(blank=True, null=True)
demo_link = models.URLField(blank=True, null=True)
img = models.CharField(max_length=200)
skills = models.ManyToManyField('Skill')
rank = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(10)])
class Category(Model):
name: CharField = CharField(max_length=100)
tag: CharField = CharField(max_length=100)
rank: IntegerField = IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(10)]
)

def __str__(self):
return self.name


class Contact(models.Model):
name = models.CharField(max_length=30)
email = models.EmailField()
subject = models.CharField(max_length=20)
message = models.TextField(max_length=40)



class Project(Model):
id: AutoField = AutoField(primary_key=True)
name: CharField = CharField(max_length=200)
short_description: CharField = CharField(max_length=300)
description: TextField = TextField()
category: ForeignKey = ForeignKey(Category, on_delete=CASCADE)
github_link: URLField = URLField(blank=True, null=True)
demo_link: URLField = URLField(blank=True, null=True)
img: CharField = CharField(max_length=200)
skills: ManyToManyField = ManyToManyField('Skill')
rank: IntegerField = IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(10)]
)

def __str__(self):
return self.name

class SkillCategory(models.Model):
name = models.CharField(max_length=100)
tag = models.CharField(max_length=100)
rank = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(10)])


class SkillCategory(Model):
name: CharField = CharField(max_length=100)
tag: CharField = CharField(max_length=100)
rank: IntegerField = IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(10)]
)

def __str__(self):
return self.name

class Skill(models.Model):
name = models.CharField(max_length=100)
category = models.ForeignKey(SkillCategory, on_delete=models.CASCADE)
level = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(100)])

class Skill(Model):
name: CharField = CharField(max_length=100)
category: ForeignKey = ForeignKey(SkillCategory, on_delete=CASCADE)
level: IntegerField = IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(100)]
)

def __str__(self):
return self.name

13 changes: 3 additions & 10 deletions home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
from django.conf.urls.static import static
from home import views

admin.site.site_header = "Login to Cristian"
admin.site.site_title = "Welcome to Dashboard"
admin.site.index_title = "Welcome my Portal"
admin.site.site_header = 'Login to Cristian'
admin.site.site_title = 'Welcome to Dashboard'
admin.site.index_title = 'Welcome my Portal'

urlpatterns = [
path('', views.home, name='home'),
path('#contact', views.contact, name='contact'),
#path('project', views.project, name='project'),
# path('skills', views.skills, name='skills'),
# path('contact', views.contact, name='contact'),
]

if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
44 changes: 27 additions & 17 deletions home/views.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
from django.shortcuts import render
from home import models
# Create your views here.
from home.models import (
Project,
Category,
SkillCategory,
Skill,
)
from django.http import (
HttpRequest,
HttpResponse,
)

def home(request):
projects = models.Project.objects.order_by('rank', 'name')
categories = models.Category.objects.order_by('rank', 'name')
skill_categories = models.SkillCategory.objects.order_by('rank', 'name')
skills = models.Skill.objects.order_by('-level', )
return render(request, 'home.html', {'projects': projects, 'categories': categories, 'skill_categories': skill_categories, 'skills': skills})

def contact(request):
if request.method == 'POST':
name = request.POST['name']
email = request.POST['email']
subject = request.POST['subject']
message = request.POST['message']
contact = models.Contact(name=name, email=email, subject=subject, message=message)
contact.save()
return render(request, 'contact.html')
def home(request: HttpRequest) -> HttpResponse:
projects = Project.objects.order_by('rank', 'name')
categories = Category.objects.order_by('rank', 'name')
skill_categories = SkillCategory.objects.order_by('rank', 'name')
skills = Skill.objects.order_by(
'-level',
)
return render(
request,
'home.html',
{
'projects': projects,
'categories': categories,
'skill_categories': skill_categories,
'skills': skills,
},
)
34 changes: 34 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
upstream django {
server web:8000; # This connects to the Gunicorn container named 'web' running on port 8000
}

server {
listen 80;

# Serve static files directly
location /static/ {
alias /app/staticfiles/; # This is the directory where Django collects static files
}

# Serve media files directly
location /media/ {
alias /app/media/; # This is the directory where media files are stored
}

# All other requests will be proxied to the Django application
location / {
proxy_pass http://django; # Passes all requests to Gunicorn
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
Loading

0 comments on commit d41be03

Please sign in to comment.