dokku shit
This commit is contained in:
57
docker-compose.yml
Normal file
57
docker-compose.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
volumes:
|
||||||
|
- database:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=werkout
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
command: >
|
||||||
|
sh -c "python manage.py collectstatic --noinput && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
- POSTGRES_NAME=werkout
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- db
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:alpine
|
||||||
|
|
||||||
|
celery:
|
||||||
|
restart: always
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
command: celery -A werkout worker -l info
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
environment:
|
||||||
|
- DB_HOST=db
|
||||||
|
- DB_NAME=werkout
|
||||||
|
- DB_USER=postgres
|
||||||
|
- DB_PASS=postgres
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
- web
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
||||||
21
dockerfile
Normal file
21
dockerfile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM python:3.9.13
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
|
||||||
|
RUN apt-get install -y swig libssl-dev dpkg-dev netcat
|
||||||
|
RUN pip install -U pip
|
||||||
|
|
||||||
|
# Add the Dokku-specific files to their locations.
|
||||||
|
ADD misc/dokku/CHECKS /app/
|
||||||
|
ADD misc/dokku/* /code/
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
COPY requirements.txt /code/
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY . /code/
|
||||||
|
|
||||||
|
RUN /code/manage.py collectstatic --noinput
|
||||||
61
dokku_notes
Normal file
61
dokku_notes
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
docker ps
|
||||||
|
docker-compose exec web python manage.py makemigrations
|
||||||
|
----------------------------------------
|
||||||
|
wget https://raw.githubusercontent.com/dokku/dokku/v0.28.1/bootstrap.sh
|
||||||
|
sudo DOKKU_TAG=v0.28.1 bash bootstrap.sh
|
||||||
|
|
||||||
|
cat ~/.ssh/authorized_keys | dokku ssh-keys:add admin
|
||||||
|
|
||||||
|
# server ip
|
||||||
|
dokku domains:set-global ###severip
|
||||||
|
|
||||||
|
sudo dokku apps:create werkout
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
|
||||||
|
sudo dokku postgres:create werkout
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis
|
||||||
|
sudo dokku redis:create werkout
|
||||||
|
|
||||||
|
sudo dokku postgres:link werkout werkout
|
||||||
|
sudo dokku redis:link werkout werkout
|
||||||
|
|
||||||
|
sudo dokku config:set --no-restart werkout SECRET_KEY=wz%C*@^$QLaFDc$u*wKZK9bV3CBMt7cj3wk2y^0vdu@2*pz7yco+p=7@sa%
|
||||||
|
|
||||||
|
#if dev env
|
||||||
|
sudo dokku config:set --no-restart werkout IS_DEV=True
|
||||||
|
|
||||||
|
#push code
|
||||||
|
# add werkoutDev and werkout to /etc/hosts
|
||||||
|
'''
|
||||||
|
Host brodkast
|
||||||
|
HostName 45.33.120.174
|
||||||
|
User root
|
||||||
|
PreferredAuthentications publickey
|
||||||
|
IdentityFile /Users/treyt/.ssh/bk_linode
|
||||||
|
IdentitiesOnly yes
|
||||||
|
AddKeysToAgent yes
|
||||||
|
# ----------------------------
|
||||||
|
Host brodkastDev
|
||||||
|
HostName 45.79.26.38
|
||||||
|
User root
|
||||||
|
PreferredAuthentications publickey
|
||||||
|
IdentityFile /Users/treyt/.ssh/bk_linode
|
||||||
|
IdentitiesOnly yes
|
||||||
|
AddKeysToAgent yes
|
||||||
|
'''
|
||||||
|
git push dokku@werkoutDev:werkout dokku
|
||||||
|
git push dokku@werkout:werkout master
|
||||||
|
|
||||||
|
dokku run werkout python manage.py createsuperuser
|
||||||
|
|
||||||
|
#check if debug
|
||||||
|
dokku run werkout python manage.py shell
|
||||||
|
from django.conf import settings
|
||||||
|
print(settings.DEBUG)
|
||||||
|
exit()
|
||||||
|
----------------------------------------
|
||||||
|
sudo dokku domains:add werkout dev.werkout.io
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
|
||||||
|
sudo dokku config:set --no-restart --global DOKKU_LETSENCRYPT_EMAIL=werkoutdev@treymail.com
|
||||||
|
sudo dokku letsencrypt:enable werkout
|
||||||
|
sudo dokku letsencrypt:cron-job --add
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-redirect.git
|
||||||
0
misc/CHECKS
Normal file
0
misc/CHECKS
Normal file
3
misc/DOKKU_SCALE
Normal file
3
misc/DOKKU_SCALE
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
web=1
|
||||||
|
worker=3
|
||||||
|
beat=1
|
||||||
3
misc/Procfile
Normal file
3
misc/Procfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
web: daphne werkout_api.asgi:application --port 5000 --bind 0.0.0.0 -v2
|
||||||
|
beat: /usr/local/bin/celery -A werkout beat -linfo
|
||||||
|
worker: python3 manage.py runworker channel_layer -v2
|
||||||
7
misc/app.json
Normal file
7
misc/app.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"dokku": {
|
||||||
|
"predeploy": "/code/manage.py migrate --noinput"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
misc/uwsgi.ini
Normal file
10
misc/uwsgi.ini
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[uwsgi]
|
||||||
|
module=werkout.wsgi:application
|
||||||
|
master=True
|
||||||
|
vacuum=True
|
||||||
|
max-requests=5000
|
||||||
|
http-socket=:5000
|
||||||
|
processes=3
|
||||||
|
harakiri=120
|
||||||
|
single-interpreter=True
|
||||||
|
enable-threads=True
|
||||||
34
requirements.txt
Normal file
34
requirements.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
amqp==5.1.1
|
||||||
|
asgiref==3.7.2
|
||||||
|
billiard==4.1.0
|
||||||
|
celery==5.3.1
|
||||||
|
click==8.1.3
|
||||||
|
click-didyoumean==0.3.0
|
||||||
|
click-plugins==1.1.1
|
||||||
|
click-repl==0.3.0
|
||||||
|
defusedxml==0.7.1
|
||||||
|
diff-match-patch==20230430
|
||||||
|
Django==4.2.2
|
||||||
|
django-debug-toolbar==4.1.0
|
||||||
|
django-import-export==3.2.0
|
||||||
|
djangorestframework==3.14.0
|
||||||
|
et-xmlfile==1.1.0
|
||||||
|
kombu==5.3.1
|
||||||
|
MarkupPy==1.14
|
||||||
|
odfpy==1.4.1
|
||||||
|
openpyxl==3.1.2
|
||||||
|
prompt-toolkit==3.0.38
|
||||||
|
psycopg2==2.9.6
|
||||||
|
python-dateutil==2.8.2
|
||||||
|
pytz==2023.3
|
||||||
|
PyYAML==6.0
|
||||||
|
six==1.16.0
|
||||||
|
sqlparse==0.4.4
|
||||||
|
tablib==3.5.0
|
||||||
|
typing_extensions==4.6.3
|
||||||
|
tzdata==2023.3
|
||||||
|
vine==5.0.0
|
||||||
|
wcwidth==0.2.6
|
||||||
|
whitenoise==6.4.0
|
||||||
|
xlrd==2.0.1
|
||||||
|
xlwt==1.3.0
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .celery import app as celery_app
|
||||||
|
|
||||||
|
__all__ = ['celery_app']
|
||||||
8
werkout_api/celery.py
Normal file
8
werkout_api/celery.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import os
|
||||||
|
from celery import Celery
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'werkout.settings')
|
||||||
|
|
||||||
|
app = Celery('werkout')
|
||||||
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||||
|
app.autodiscover_tasks()
|
||||||
@@ -9,7 +9,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-o_0sbr3lxcy#_r#imo4tl0cw*%@*__2a48dcd6hbp&u9b5dx=1'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
@@ -76,13 +76,6 @@ WSGI_APPLICATION = 'werkout_api.wsgi.application'
|
|||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
||||||
@@ -123,3 +116,91 @@ STATIC_URL = 'static/'
|
|||||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||||
|
|
||||||
|
|
||||||
|
if os.environ.get("DATABASE_URL"):
|
||||||
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
# if os.environ.get("IS_DEV"):
|
||||||
|
# DEBUG = True
|
||||||
|
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||||
|
# "APNS_CERTIFICATE": "certs/dev/prod_aps.pem",
|
||||||
|
# "APNS_TOPIC": "io.brodkast.ios-Dev",
|
||||||
|
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||||
|
# "APNS_USE_SANDBOX": False
|
||||||
|
# }
|
||||||
|
# else:
|
||||||
|
# DEBUG = False
|
||||||
|
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||||
|
# "APNS_CERTIFICATE": "certs/prod/prod_aps.pem",
|
||||||
|
# "APNS_TOPIC": "io.brodkast.ios",
|
||||||
|
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||||
|
# "APNS_USE_SANDBOX": False
|
||||||
|
# }
|
||||||
|
|
||||||
|
CSRF_TRUSTED_ORIGINS = ['https://*.werkout.io']
|
||||||
|
SECRET_KEY = os.environ.get("SECRET_KEY", 'secret')
|
||||||
|
|
||||||
|
# Parse the DATABASE_URL env var.
|
||||||
|
USER, PASSWORD, HOST, PORT, NAME = re.match("^postgres://(?P<username>.*?)\:(?P<password>.*?)\@(?P<host>.*?)\:(?P<port>\d+)\/(?P<db>.*?)$", os.environ.get("DATABASE_URL", "")).groups()
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': NAME,
|
||||||
|
'USER': USER,
|
||||||
|
'PASSWORD': PASSWORD,
|
||||||
|
'HOST': HOST,
|
||||||
|
'PORT': int(PORT),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CELERY_BROKER_URL = os.environ.get("REDIS_URL", "") + "/1"
|
||||||
|
CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL", "") + "/1"
|
||||||
|
|
||||||
|
CHANNEL_LAYERS = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
||||||
|
"CONFIG": {
|
||||||
|
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERNAL_IPS = [
|
||||||
|
"127.0.0.1",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
DEBUG = True
|
||||||
|
ALLOWED_HOSTS = ['*']
|
||||||
|
SECRET_KEY = 'django-insecure-o_0sbr3lxcy#_r#imo4tl0cw*%@*__2a48dcd6hbp&u9b5dx=1'
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CELERY_BROKER_URL = "redis://redis:6379"
|
||||||
|
CELERY_RESULT_BACKEND = "redis://redis:6379"
|
||||||
|
|
||||||
|
CHANNEL_LAYERS = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
||||||
|
'CONFIG': {
|
||||||
|
'hosts': [('redis', 6379)],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERNAL_IPS = [
|
||||||
|
"127.0.0.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||||
|
# "APNS_CERTIFICATE": "certs/dev/dev_aps.pem",
|
||||||
|
# "APNS_TOPIC": "io.brodkast.ios-Dev",
|
||||||
|
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||||
|
# "APNS_USE_SANDBOX": True
|
||||||
|
# }
|
||||||
Reference in New Issue
Block a user