File tree 9 files changed +70
-1
lines changed
9 files changed +70
-1
lines changed Original file line number Diff line number Diff line change 30
30
run : python manage.py migrate
31
31
- name : Run tests
32
32
run : py.test
33
+ deploy_to_heroku :
34
+ runs-on : ubuntu-latest
35
+ needs : build
36
+ if : github.ref == 'refs/heads/master'
37
+ steps :
38
+ - uses : actions/checkout@v1
39
+ - name : Deploy to Heroku
40
+ env :
41
+ HEROKU_API_KEY : ${{ secrets.HEROKU_API_KEY }}
42
+ HEROKU_APP_NAME : ' hacksoft-styleguide-example'
43
+ run :
git push --force https://heroku:[email protected] /$HEROKU_APP_NAME.git origin/master:master
Original file line number Diff line number Diff line change
1
+ release : python manage.py migrate
2
+ web : gunicorn config.wsgi:application
3
+ worker : REMAP_SIGTERM=SIGQUIT celery --without-gossip --without-mingle --without-heartbeat worker -A styleguide_example.tasks -l info
4
+ beat : REMAP_SIGTERM=SIGQUIT celery -A styleguide_example.tasks beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ Few important things:
9
9
* Linux / Ubuntu is our primary OS and things are tested for that. It will mostly not work on Mac & certainly not work on Windows.
10
10
* It uses Postgres as primary database.
11
11
* It comes with GitHub Actions support, [ based on that article] ( https://hacksoft.io/github-actions-in-action-setting-up-django-and-postgres/ )
12
+ * It comes with [ ` whitenoise ` ] ( http://whitenoise.evans.io/en/stable/ ) setup.
13
+ * It can be easily deployed to Heroku.
12
14
13
15
## Helpful commands
14
16
@@ -35,3 +37,7 @@ To start Celery Beat:
35
37
```
36
38
celery -A styleguide_example.tasks beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
37
39
```
40
+
41
+ ## Heroku
42
+
43
+ The project is ready to be deployed on Heroku. There's a current deployment that can be found - < https://hacksoft-styleguide-example.herokuapp.com/ >
Original file line number Diff line number Diff line change 59
59
60
60
MIDDLEWARE = [
61
61
'django.middleware.security.SecurityMiddleware' ,
62
+ 'whitenoise.middleware.WhiteNoiseMiddleware' ,
62
63
'django.contrib.sessions.middleware.SessionMiddleware' ,
63
64
'django.middleware.common.CommonMiddleware' ,
64
65
'django.middleware.csrf.CsrfViewMiddleware' ,
147
148
# Static files (CSS, JavaScript, Images)
148
149
# https://docs.djangoproject.com/en/3.0/howto/static-files/
149
150
151
+ STATIC_ROOT = os .path .join (BASE_DIR , 'staticfiles' )
150
152
STATIC_URL = '/static/'
153
+ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
154
+
151
155
152
156
# https://django-rest-framework-simplejwt.readthedocs.io/en/latest/settings.html
153
157
SIMPLE_JWT = {
Original file line number Diff line number Diff line change
1
+ from .base import * # noqa
2
+ from .env_reader import env
3
+
4
+ DEBUG = env .bool ('DJANGO_DEBUG' , default = False )
5
+
6
+ SECRET_KEY = env ('DJANGO_SECRET_KEY' )
7
+
8
+ ALLOWED_HOSTS = env .list ('DJANGO_ALLOWED_HOSTS' , default = [])
9
+
10
+ # https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
11
+ SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO" , "https" )
12
+ # https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
13
+ SECURE_SSL_REDIRECT = env .bool ("DJANGO_SECURE_SSL_REDIRECT" , default = True )
14
+ # https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
15
+ SESSION_COOKIE_SECURE = True
16
+ # https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
17
+ CSRF_COOKIE_SECURE = True
18
+ # https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
19
+ SECURE_CONTENT_TYPE_NOSNIFF = env .bool (
20
+ "DJANGO_SECURE_CONTENT_TYPE_NOSNIFF" , default = True
21
+ )
22
+
23
+ SENTRY_DSN = env ('DJANGO_SENTRY_DSN' , default = '' )
24
+
25
+ if SENTRY_DSN :
26
+ import sentry_sdk
27
+ from sentry_sdk .integrations .django import DjangoIntegration
28
+ from sentry_sdk .integrations .celery import CeleryIntegration
29
+
30
+ sentry_sdk .init (
31
+ dsn = SENTRY_DSN ,
32
+ integrations = [
33
+ DjangoIntegration (),
34
+ CeleryIntegration (),
35
+ ]
36
+ )
Original file line number Diff line number Diff line change 1
- -r requirements/base .txt
1
+ -r requirements/production .txt
Original file line number Diff line number Diff line change @@ -7,3 +7,5 @@ djangorestframework-simplejwt==4.4.0
7
7
celery==4.4.6
8
8
django-celery-results==1.2.1
9
9
django-celery-beat==2.0.0
10
+
11
+ whitenoise==5.1.0
Original file line number Diff line number Diff line change
1
+ -r base.txt
2
+
3
+ whitenoise==5.1.0
4
+ gunicorn==20.0.4
5
+ sentry-sdk==0.16.0
Original file line number Diff line number Diff line change
1
+ python-3.7.7
You can’t perform that action at this time.
0 commit comments