Skip to content

Latest commit

 

History

History
139 lines (96 loc) · 3.4 KB

File metadata and controls

139 lines (96 loc) · 3.4 KB

Development

Setup your <%= project_name %> development environment:

./scripts/install.sh

And start developing

./scripts/start.sh

Docker

You can run the entire web app with all the necessary services inside Docker:

docker-compose up

To run python manage.py commands use docker-compose run cli instead:

docker-compose run cli migrate
docker-compose run cli createsuperuser

If you want to run Django with runserver for better debug output, update the docker-compose.yml file.

Frontend details

<% if (prod_branch) { %> When you call ./deploy.sh everything gets compiled into a prod/ folder, including minified frontend code, commited into a prod branch and pushed to Heroku.

Note that create-react-app includes a service worker that caches everything into local storage which is good for performance reasons, but messes up routing for server-side routes like /admin. If you still wish to use these, disable the service worker by commenting out the line registerServiceWorker(); in index.js. <% } %>

Deployment

You can deploy your Django web app to different PaaS providers in just a few commands.

Heroku

You can quickly deploy <%= project_name %> to Heroku:

heroku login
heroku create <%= project_name %>
heroku git:remote -a <%= project_name %>
heroku addons:create heroku-postgresql:hobby-dev # for the DB
heroku addons:create heroku-redis:hobby-dev # for Celery
./scripts/deploy.sh
heroku run python manage.py migrate

Once this initial setup is working, you normally deploy by issuing:

./scripts/deploy.sh

And you're running on Heroku! 🚀

Dokku

Dokku is an alternative to Heroku that you can self-host. We assume that your Dokku server uses the hostname (and email) dokku.me in the commands bellow – replace with your actual information.

SSH into your Dokku host and create the app:

dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku plugin:install https://github.com/dokku/dokku-redis.git
dokku apps:create <%= project_name %>
dokku postgres:create <%= project_name %>db
dokku postgres:link <%= project_name %>db <%= project_name %>
dokku redis:create <%= project_name %>redis
dokku redis:link <%= project_name %>redis <%= project_name %>
dokku config:set --no-restart <%= project_name %> DOKKU_LETSENCRYPT_EMAIL=youremail@dokku.me

Inside your project do:

git remote add dokku dokku@dokku.me:<%= project_name %>
git push dokku master

Now a few more commands on the server:

dokku letsencrypt <%= project_name %>
dokku run <%= project_name %> python manage.py migrate

That's it! Your app should be live on https://<%= project_name %>.dokku.me 🚀

Upgrading the scaffolding

The scaffolding for this Django project was built using generator-django-rest. To upgrade your project with the latest version of generator-django-rest install node and get these npm package:

npm install -g yo generator-django-rest

If you use yarn instead do:

yarn global add yo generator-django-rest
yarn global upgrade yo generator-django-rest

Then from within the root of your project (the path containing this file) run:

yo django-rest

And resolve any conflicts using the interactive prompts.