diff --git a/.gitignore b/.gitignore index 6b6867e..873d9a1 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,6 @@ media/historicos /load_test/files/* # Coverage -.coveragerc \ No newline at end of file +.coveragerc + +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8f85d26..5100c9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.11 WORKDIR /projetin -COPY requirements.txt . +COPY requirements/requirements.txt . RUN pip install --upgrade pip && \ pip install --no-cache-dir -r requirements.txt @@ -16,4 +16,4 @@ COPY manage.py . EXPOSE 8080 -CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file +CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/backend/settings.py b/backend/settings.py index 7870186..6bf7d4e 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -29,7 +29,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['backend-0ytn.onrender.com', 'localhost', '127.0.0.1'] # Application definition @@ -109,15 +109,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'postgres', - 'USER': 'postgres', - 'PASSWORD': 'postgres', - 'HOST': 'postgres_db', - 'PORT': '5432', + 'NAME': os.getenv('DB_NAME', 'postgres'), + 'USER': os.getenv('DB_USER', 'postgres'), + 'PASSWORD': os.getenv('DB_PASSWORD', 'postgres'), + 'HOST': os.getenv('DB_HOST', 'db'), + 'PORT': os.getenv('DB_PORT', '5432'), } } + # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators @@ -162,9 +163,11 @@ CORS_ORIGIN_ALLOW_ALL = True -# CORS_ALLOWED_ORIGINS = [ -# 'http://localhost:8000', -# ] +CORS_ALLOWED_ORIGINS = [ + 'https://frontend-ashen-seven-61.vercel.app', +] + +CORS_ALLOW_CREDENTIALS = True MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 2eff19f..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -services: - web: - build: . - container_name: projetin - command: python3 manage.py runserver 0.0.0.0:8000 - volumes: - - .:/projetin - ports: - - "8000:8000" - environment: - - DEBUG=1 - - DB_NAME=postgres - - DB_USER=postgres - - DB_PASSWORD=postgres - - DB_HOST=db - - DB_PORT=5432 - depends_on: - - db - - db: - image: postgres:15 - container_name: postgres_db - volumes: - - postgres_data:/var/lib/postgresql/data - environment: - POSTGRES_DB: postgres - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - -volumes: - postgres_data: diff --git a/requirements/requirements.txt b/requirements/requirements.txt index f69ce78..088aae7 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -22,4 +22,5 @@ tzdata==2024.1 urllib3==2.2.3 autopep8==2.3.1 pylint==3.3.0 -bandit==1.7.9 \ No newline at end of file +bandit==1.7.9 +gunicorn==23.0.0 \ No newline at end of file