A fork of babybuddy so that I can build a tracker for my grown-ass self.
Go to file
Christopher Charbonneau Wells 4844d5f69b Update Nanobox and AWS deployment configs to use cleaner pipenv install command. 2017-11-29 14:05:09 -05:00
.ebextensions Update Nanobox and AWS deployment configs to use cleaner pipenv install command. 2017-11-29 14:05:09 -05:00
api Add weight tracking. 2017-11-09 21:15:09 -05:00
babybuddy Update docker-compose config using an environment file. 2017-11-24 11:36:02 -05:00
core Merge pull request #20 from overshard/master 2017-11-19 08:40:27 -05:00
dashboard Add Python 2.7 workaround for Dashboard tests and add missing `__init__.py` file. 2017-11-19 12:39:59 -05:00
etc Add nanobox config files. 2017-11-13 16:21:33 -05:00
gulpfile.js Add ability to upload picture of child with thumbnailing capabilities. 2017-11-18 04:22:12 -05:00
reports Replace deprecating pandas methods. 2017-11-18 07:42:48 -05:00
.coveragerc Add specific, fixtures-based tests for Dashboard cards. 2017-11-19 11:13:35 -05:00
.gitignore Update docker-compose config using an environment file. 2017-11-24 11:36:02 -05:00
.travis.yml Refactor gulp commands and travis config for whitenoise integration. 2017-10-23 13:50:20 -04:00
Dockerfile Tweak Docker config files and add documentation. 2017-11-24 14:39:20 -05:00
LICENSE Add LICENSE and README. 2017-10-22 16:00:29 -04:00
Pipfile Add ability to upload picture of child with thumbnailing capabilities. 2017-11-18 04:22:12 -05:00
Pipfile.lock Update Pipfile.lock. 2017-11-18 06:11:51 -05:00
Procfile Add Heroku Procfile. 2017-10-23 04:37:23 -04:00
README.md Use `exec` instead of `run` in Docker init steps. 2017-11-26 14:04:07 -05:00
app.json Shorten app.json description to meet below 140 characters requirement. 2017-10-23 20:24:53 -04:00
boxfile.yml Update Nanobox and AWS deployment configs to use cleaner pipenv install command. 2017-11-29 14:05:09 -05:00
docker-compose.yml Use `exec` instead of `run` in Docker init steps. 2017-11-26 14:04:07 -05:00
docker.env.example Tweak Docker config files and add documentation. 2017-11-24 14:39:20 -05:00
manage.py Set default settings file in manage.py and wsgi.py. 2017-10-22 16:19:59 -04:00
package-lock.json Add nanobox config files. 2017-11-13 16:21:33 -05:00
package.json Improve Dashboard view. 2017-11-06 16:24:21 -05:00
screenshot.png Update screenshot and add mobile screenshots. 2017-10-27 23:20:52 -04:00
screenshot_mobile.png Update screenshot and add mobile screenshots. 2017-10-27 23:20:52 -04:00

README.md

Baby Buddy

Build Status Coverage Status License Gitter

A buddy for babies! Helps caregivers track sleep, feedings, diaper changes, and tummy time to learn about and predict baby's needs without (as much) guess work.

Baby Buddy desktop view

Baby Buddy mobile views

Table of Contents

Demo

A demo of Baby Buddy is available on Heroku. The demo instance resets every hour. Login credentials are:

  • Username: admin
  • Password: admin

Deployment

⚠️ Baby Buddy is still in early development and does not yet have a stable production deployment flow. ⚠️

The default user name and password for Baby Buddy is admin/admin. For any deployment, log in and change the default password immediately.

AWS Elastic Beanstalk

A basic Elastic Beanstalk configuration is provided in .ebextensions/babybuddy.config. The steps below are a rough guide to deployment. See Working with Python for detailed information.

  1. Clone/download the Baby Buddy repo

     git clone https://github.com/cdubz/babybuddy.git
    
  2. Enter the cloned/downloaded directory

     cd babybuddy
    
  3. Change the SECRET_KEY value to something random in .ebextensions/babybuddy.config

  4. Create an IAM user in AWS with EB, EC2, RDS and S3 privileges.

  5. Initialize the Elastic Bean application (using the IAM user from the previous step)

     eb init
    
  6. Create/deploy the environment! 🚀

     eb create -db -db.engine postgres
    

The create command will also do an initial deployment. Run eb deploy to redeploy the app (e.g. if there are errors or settings are changed).

Docker

A Docker deploy requires Docker and Docker Compose to create two containers - one for the database and one for the application.

  1. Copy the docker.env.example to docker.env and set the ALLOWED_HOSTS and SECRET_KEY variables within

     cp docker.env.example docker.env
     editor docker.env
    
  2. Build/run the application

     docker-compose up -d
    
  3. Initialize the database (first run/after updates)

     docker-compose exec app python manage.py migrate
    
  4. Initialize static assets (first run/after updates)

     docker-compose exec app python manage.py collectstatic
    

The app should now be locally available at http://127.0.0.1:8000. See Get Started, Part 6: Deploy your app for detailed information about how to deployment methods with Docker.

Nanobox

An example Nanobox configuration, boxfile.yml, is provided with Baby Buddy. The steps below are a rough guide to deployment. See Create and Deploy a Custom Django App for detailed information about Nanobox's deployment and configuration process.

  1. Clone/download the Baby Buddy repo

     git clone https://github.com/cdubz/babybuddy.git
    
  2. Enter the cloned/downloaded directory

     cd babybuddy
    
  3. Add the SECRET_KEY and DJANGO_SETTINGS_MODULE environment variables

     nanobox evar add DJANGO_SETTINGS_MODULE=babybuddy.settings.nanobox
     nanobox evar add SECRET_KEY=<CHANGE TO SOMETHING RANDOM>
    
  4. Deploy! 🚀

     nanobox deploy
    

Heroku

Deploy

For manual deployments to Heroku without using the deploy button, make sure to create two settings before pushing using heroku config:set:

heroku config:set DJANGO_SETTINGS_MODULE=babybuddy.settings.heroku
heroku config:set SECRET_KEY=<CHANGE TO SOMETHING RANDOM>

Manual

There are a number of ways to deploy Baby Buddy manually to any server/VPS. The application can run fine in low memory (below 1GB) situations, however a 32-bit operating system is recommended in such cases. This is primarily because the build process can be memory intensive and cause excessive memory usage on 64-bit systems. If all fails, assets can be built on a local machine and then uploaded to a server.

Requirements

  • Python 2.7+, pip, pipenv
  • Web server (nginx, Apache, etc.)
  • Application server (uwsgi, gunicorn, etc.)
  • Database (sqlite, Postgres, MySQL, etc.)
  • NodeJS 8.x and NPM 5.x (for building assets)
  • Gulp (for building assets)

Example deployment

This example assumes a 512MB VPS instance with Ubuntu 16.04 x32. It uses Python 3.x, nginx, uwsgi and sqlite and should be sufficient for a few users (e.g. two parents and 1+ child).

  1. Install Python 3.x, pip, nginx and uwsgi

     sudo apt-get install python3 python3-pip nginx uwsgi uwsgi-plugin-python3
    
  2. Install pipenv

     sudo -H pip install pipenv
    
  3. Install NodeJS, NPM and Gulp

     curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
     sudo apt-get install nodejs
     sudo npm install -g gulp-cli
    
  4. Set up directories and files

     sudo mkdir /var/www/babybuddy
     sudo chown user:user /var/www/babybuddy
     mkdir -p /var/www/babybuddy/data/media
     sudo chown -R www-data:www-data /var/www/babybuddy/data
     git clone https://github.com/cdubz/babybuddy.git /var/www/babybuddy/public
    
  5. Move in to the application folder

     cd /var/www/babybuddy/public
    
  6. Initiate the Python environment

     pipenv --three --dev
    
  7. Build static assets

     npm install
     gulp build
    
  8. Create a production settings file and set the SECRET_KEY and ALLOWED_HOSTS values

     cp babybuddy/settings/production.example.py babybuddy/settings/production.py
     editor babybuddy/settings/production.py
    
  9. Initiate the application

     export DJANGO_SETTINGS_MODULE=babybuddy.settings.production
     gulp collectstatic
     gulp migrate
    
  10. Set appropriate permissions on the database and data folder

     sudo chown www-data:www-data /var/www/babybuddy/data/db.sqlite3
     sudo chmod 640 /var/www/babybuddy/data/db.sqlite3
     sudo chmod 750 /var/www/babybuddy/data
    
  11. Create and configure the uwsgi app

     sudo editor /etc/uwsgi/apps-available/babybuddy.ini
     sudo ln -s /etc/uwsgi/apps-available/babybuddy.ini /etc/uwsgi/apps-enabled/babybuddy.ini
     sudo service uwsgi restart
    

    Example config:

     [uwsgi]
     plugins = python3
     project = babybuddy
     base_dir = /var/www/babybuddy
    
     virtualenv = /home/user/.local/share/virtualenvs/babybuddy-XXXXXXXX
     chdir = %(base_dir)/babybuddy
     module =  %(project).wsgi:application
     env = DJANGO_SETTINGS_MODULE=%(project).settings.production
     master = True
     vacuum = True
    

    See the uWSGI documentation for more advanced configuration details.

    Note: Find the location of the pipenv virtual environment with the command pipenv --venv.

  12. Create and configure the nginx server

     sudo vim /etc/nginx/sites-available/babybuddy
     sudo ln -s /etc/nginx/sites-available/babybuddy /etc/nginx/sites-enabled/babybuddy
     sudo service nginx restart
    

    Example config:

     upstream babybuddy {
         server unix:///var/run/uwsgi/app/babybuddy/socket;
     }
    
     server {
         listen 80;
         server_name babybuddy.example.com;
    
         location / {
             uwsgi_pass babybuddy;
             include uwsgi_params;
         }
     }
    

    See the nginx documentation for more advanced configuration details.

  13. That's it (hopefully)! 🎉

Development

Installation

pip install pipenv
pipenv install --dev
npm install -g gulp-cli
npm install
gulp migrate
gulp

Open http://127.0.0.1:8000 and log in with the default user name and password (admin/admin).

Fake data

Add some fake data to the database with the following command:

gulp fake

By default, fake creates one child and 31 days of random data. Use the --children and --days flags to change the default values, e.g. gulp fake --children 5 --days 7 to generate five fake children and seven days of data for each.

Testing

Tests require static files to be collected, it may be necessary to execute gulp build && gulp collectstatic before tests (if static files have changed).

gulp test