Skip to content

Commit

Permalink
first bot try
Browse files Browse the repository at this point in the history
  • Loading branch information
Murrengan1 committed Aug 26, 2020
1 parent 8784f06 commit ee85449
Show file tree
Hide file tree
Showing 25 changed files with 25,295 additions and 15 deletions.
11 changes: 1 addition & 10 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DEBUG=1
SECRET_KEY=+ownf%0op*r)rytn0^u38y7sbp_w6nf-uf9cbtm0sk2o#b1^bj
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 35.228.83.205 murrengan.ru www.murrengan.ru [::1]
DATABASE=postgres

SQL_ENGINE=django.db.backends.postgresql
Expand All @@ -10,12 +9,4 @@ SQL_PASSWORD=murr_postgres_password
SQL_HOST=db
SQL_PORT=5432

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_USE_TLS=True
EMAIL_HOST=smtp.gmail.com
EMAIL_HOST_USER=[email protected]
EMAIL_PORT=587
EMAIL_HOST_PASSWORD=iufotejcfyojsgby

BASE_URL=https://murrengan.ru
LOCALHOST=https://murrengan.ru
REDIS_HOST=redis
24 changes: 24 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
DEBUG=1
SECRET_KEY=+ownf%0op*r)rytn0^u38y7sbp_w6nf-uf9cbtm0sk2o#b1^bj
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 35.228.83.205 murrengan.ru www.murrengan.ru [::1]
DATABASE=postgres

SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=murr_postgres_bd
SQL_USER=murr_postgres_user
SQL_PASSWORD=murr_postgres_password
SQL_HOST=db
SQL_PORT=5432

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_USE_TLS=True
EMAIL_HOST=smtp.gmail.com
EMAIL_HOST_USER=[email protected]
EMAIL_PORT=587
EMAIL_HOST_PASSWORD=iufotejcfyojsgby

BASE_URL=https://murrengan.ru
LOCALHOST=https://murrengan.ru

REDIS_HOST=redis
BOT_TOKEN=737836476:AAE8WivMe26JfPm0hu28mAkBzpuxf5fs6Kk
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ ENV PYTHONUNBUFFERED 1

RUN pip install --upgrade pip

COPY ./requirements.txt /home/murrengan/requirements.txt
COPY requirements.txt /home/murrengan/requirements.txt
RUN pip install -r requirements.txt
RUN pip install gunicorn

RUN apt-get update && apt-get install netcat -y

COPY . /home/murrengan
RUN mkdir /home/murrengan/static

ENTRYPOINT ["/home/murrengan/entrypoint.sh"]
12 changes: 12 additions & 0 deletions Dockerfile_bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.7-slim
WORKDIR /home/murrengan_bot

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN pip install --upgrade pip

COPY ./requirements.txt /home/murrengan_bot/requirements.txt
RUN pip install -r requirements.txt

COPY . /home/murrengan_bot
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ pytest
Сделать файл entrypoint.sh исполняемым (sudo chmod +x entrypoint.sh)
Запустить sudo docker-compose up --build (-d для детач режима)
Для https получить origin_ca_rsa_root.pem и private_origin_ca_ecc_root.pem сертификаты у cloudflare.com и разместить их в ./nginx
```

### Установка на dev через Docker
```
Сделать файл entrypoint.sh исполняемым (sudo chmod +x entrypoint.sh)
Запустить docker-compose -f docker-compose-dev.yml up --build (-d для детач режима)
```
#### Если ты на windows - убедись, что для entrypoint.sh стоит line separator LF вместо CRLF (можно сменить в pycharm )
<br/>

<h2 align="center">Скачивай, тренируйся и принимай участие в улучшении функционала!❤</h2>
Expand Down
54 changes: 54 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: '3.7'

services:
django:
build: .
command: python manage.py runserver 0.0.0.0:7391
env_file:
- .env.dev
depends_on:
- db
expose:
- 7391
volumes:
- static_volume:/home/murrengan/staticfiles
- ./media:/home/murrengan/media
- ./:/home/murrengan
db:
image: postgres:11
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=murr_postgres_user
- POSTGRES_PASSWORD=murr_postgres_password
- POSTGRES_DB=murr_postgres_bd
nginx:
image: nginx:mainline-alpine
ports:
- 8000:8000
- 80:8000
volumes:
- static_volume:/home/murrengan/staticfiles
- ./media:/home/murrengan/media
- ./dist:/home/murrengan/murr_front/dist
- ./nginx/dev:/etc/nginx/conf.d
depends_on:
- django
redis:
image: redis:latest
bot:
build:
context: ./
dockerfile: Dockerfile_bot
command: python manage.py bot
env_file:
- .env.dev
depends_on:
- db

volumes:
postgres_data:
static_volume:
media:
dist:
redisdata:
13 changes: 12 additions & 1 deletion docker-compose.yml → docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build: .
command: gunicorn murr_back.wsgi:application --bind 0.0.0.0:8000
env_file:
- ./.env.dev
- .env.prod
depends_on:
- db
expose:
Expand Down Expand Up @@ -33,6 +33,17 @@ services:
- ./nginx:/etc/nginx/conf.d
depends_on:
- django
redis:
image: redis:latest
bot:
build:
context: ./
dockerfile: Dockerfile_bot
command: python manage.py bot
env_file:
- .env.prod
depends_on:
- db
volumes:
postgres_data:
static_volume:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ then
fi

python manage.py migrate
python manage.py collectstatic --no-input --clear
python manage.py collectstatic --no-input

exec "$@"
1 change: 1 addition & 0 deletions murr_back/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'murren.apps.MurrenConfig',
'murr_card.apps.MurrCardConfig',
'murr_chat.apps.MurrChatConfig',
'murr_bot.apps.MurrBotConfig'
]

MIDDLEWARE = [
Expand Down
Empty file added murr_bot/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions murr_bot/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Coub

admin.site.register(Coub)
Loading

0 comments on commit ee85449

Please sign in to comment.