added dockerfile, requirements.txt, docker-compose.yml
This commit is contained in:
parent
7f28fe580d
commit
456551cd4e
24 changed files with 58 additions and 7 deletions
20
Dockerfile
Normal file
20
Dockerfile
Normal 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"]
|
||||||
BIN
api/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
api/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/admin.cpython-311.pyc
Normal file
BIN
api/__pycache__/admin.cpython-311.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/apps.cpython-311.pyc
Normal file
BIN
api/__pycache__/apps.cpython-311.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/models.cpython-311.pyc
Normal file
BIN
api/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/serializers.cpython-311.pyc
Normal file
BIN
api/__pycache__/serializers.cpython-311.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/urls.cpython-311.pyc
Normal file
BIN
api/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
api/__pycache__/views.cpython-311.pyc
Normal file
BIN
api/__pycache__/views.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
api/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
api/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
api/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
api/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
|
|
@ -6,5 +6,5 @@ urlpatterns = [
|
||||||
path('predictions', PredictionCreateView.as_view(), name='create_prediction'),
|
path('predictions', PredictionCreateView.as_view(), name='create_prediction'),
|
||||||
path('predictions', PredictionListView.as_view(), name='get_predictions'),
|
path('predictions', PredictionListView.as_view(), name='get_predictions'),
|
||||||
path('predictions/<uuid:pk>', PredictionDeleteView.as_view(), name='delete_prediction'),
|
path('predictions/<uuid:pk>', PredictionDeleteView.as_view(), name='delete_prediction'),
|
||||||
path('api/token/', obtain_auth_token),
|
path('token/', obtain_auth_token),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
21
docker-compose.yml
Normal file
21
docker-compose.yml
Normal 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
6
requirements.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
Django>=4.0,<5.0
|
||||||
|
djangorestframework
|
||||||
|
djangorestframework-simplejwt
|
||||||
|
psycopg2-binary
|
||||||
|
drf-spectacular
|
||||||
|
requests
|
||||||
BIN
testapi/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
testapi/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
testapi/__pycache__/settings.cpython-311.pyc
Normal file
BIN
testapi/__pycache__/settings.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
testapi/__pycache__/urls.cpython-311.pyc
Normal file
BIN
testapi/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
testapi/__pycache__/wsgi.cpython-311.pyc
Normal file
BIN
testapi/__pycache__/wsgi.cpython-311.pyc
Normal file
Binary file not shown.
|
|
@ -78,13 +78,17 @@ WSGI_APPLICATION = 'testapi.wsgi.application'
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||||
|
|
||||||
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': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': 'drfapi', # Your database name
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
'USER': 'postgres', # Your PostgreSQL username
|
|
||||||
'PASSWORD': '1235', # Your PostgreSQL password
|
|
||||||
'HOST': 'localhost', # Or your DB server's IP
|
|
||||||
'PORT': '5432', # Default PostgreSQL port
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue