Added Docker

This commit is contained in:
ayxan 2022-10-01 17:55:04 +04:00
parent ad04604b6c
commit e613fe1874
7 changed files with 46 additions and 6 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
src/celerybeat-schedule
src/.env.example
src/db.sqlite3
config/db/databasepostgresql_env.example
**/__pycache__

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ src/config/settings/static
.env .env
Backup-codes-series.notification.txt Backup-codes-series.notification.txt
celerybeat-schedule celerybeat-schedule
databasepostgresql_env

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY src /code/src/
COPY config /code/config/

View File

@ -0,0 +1,3 @@
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
version: "3.9"
services:
db:
image: postgres
volumes:
- dbdata:/var/lib/postgresql/data
env_file:
- config/db/databasepostgresql_env
django:
build: .
command: python3 src/manage.py runserver 0.0.0.0:8000 --settings=config.settings.production
ports:
- "8000:8000"
depends_on:
- db
volumes:
dbdata:

View File

@ -15,11 +15,12 @@ django-autoslug==1.9.8
django-compat==1.0.15 django-compat==1.0.15
django-crispy-forms==1.14.0 django-crispy-forms==1.14.0
django-environ==0.9.0 django-environ==0.9.0
django-smtp-ssl django-smtp-ssl==1.0
idna==3.3 idna==3.3
kombu==5.2.4 kombu==5.2.4
packaging==21.3 packaging==21.3
prompt-toolkit==3.0.31 prompt-toolkit==3.0.31
psycopg2==2.9.3
pyparsing==3.0.9 pyparsing==3.0.9
pytz==2022.2.1 pytz==2022.2.1
redis==4.3.4 redis==4.3.4

View File

@ -3,7 +3,7 @@ from .base import *
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = ['*']
DATABASES = { DATABASES = {
'default': { 'default': {
@ -11,10 +11,12 @@ DATABASES = {
'NAME': env('DB_NAME'), 'NAME': env('DB_NAME'),
'USER': env('DB_USER'), 'USER': env('DB_USER'),
'PASSWORD': env('DB_PASSWORD'), 'PASSWORD': env('DB_PASSWORD'),
'HOST': 'databasepostgresql', 'HOST': 'db',
'PORT': '5432', 'PORT': '5432',
} }
} }
STATIC_URL = '/django_static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(BASE_DIR)), 'opt/services/djangoapp/django_static') STATICFILES_DIRS = [
BASE_DIR / 'static'
]