added dockerfile, requirements.txt, docker-compose.yml

This commit is contained in:
afanasyev.aa 2025-04-04 18:46:13 +09:00
parent 7f28fe580d
commit 456551cd4e
24 changed files with 58 additions and 7 deletions

20
Dockerfile Normal file
View file

@ -0,0 +1,20 @@
# Базовый образ
FROM python:3.11
# Устанавливаем рабочую директорию внутри контейнера
WORKDIR /app
# Копируем зависимости
COPY requirements.txt .
# Устанавливаем зависимости
RUN pip install --no-cache-dir -r requirements.txt
# Копируем все файлы проекта
COPY . .
# Открываем порт (опционально, если хочешь)
EXPOSE 8000
# Запускаем сервер
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -6,5 +6,5 @@ urlpatterns = [
path('predictions', PredictionCreateView.as_view(), name='create_prediction'),
path('predictions', PredictionListView.as_view(), name='get_predictions'),
path('predictions/<uuid:pk>', PredictionDeleteView.as_view(), name='delete_prediction'),
path('api/token/', obtain_auth_token),
path('token/', obtain_auth_token),
]

Binary file not shown.

21
docker-compose.yml Normal file
View file

@ -0,0 +1,21 @@
version: '3.9'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- .:/app
depends_on:
- db
db:
image: postgres:14
environment:
POSTGRES_DB: testapi
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"

6
requirements.txt Normal file
View file

@ -0,0 +1,6 @@
Django>=4.0,<5.0
djangorestframework
djangorestframework-simplejwt
psycopg2-binary
drf-spectacular
requests

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -78,13 +78,17 @@ WSGI_APPLICATION = 'testapi.wsgi.application'
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'drfapi', # Your database name
# 'USER': 'postgres', # Your PostgreSQL username
# 'PASSWORD': '1235', # Your PostgreSQL password
# 'HOST': 'localhost', # Or your DB server's IP
# 'PORT': '5432', # Default PostgreSQL port
# }
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'drfapi', # Your database name
'USER': 'postgres', # Your PostgreSQL username
'PASSWORD': '1235', # Your PostgreSQL password
'HOST': 'localhost', # Or your DB server's IP
'PORT': '5432', # Default PostgreSQL port
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}