/Wagtail-pipit_simple_blog

Wagtail-pipit SimpleBlog

Primary LanguagePython

SimpleBlog

Index

Requirements

Installation

  1. Setup container .env files

    cp docker/config/python.example.env docker/config/python.env
    
  2. Include this ip on your hosts-file

    127.0.0.1 SimpleBlog.com.test
    

    On windows you can run this command to append it:

    echo 127.0.0.1 SimpleBlog.com.test >> c:\windows\System32\drivers\etc\hosts
    
  3. Add root cert: mkcert -install (if not already available)

  4. Generate ssl certs for local development

    mkcert --cert-file docker/files/certs/cert.pem --key-file docker/files/certs/cert-key.pem SimpleBlog.com.test
    
  5. Enable SSL in Nginx

    sed -i.bak 's/\#mkcert\ //g' docker/files/config/nginx.conf.template
    rm -f docker/files/config/nginx.conf.template.bak
    
  6. Start project

    docker-compose up
    
  7. Install and start frontend

    cd frontend
    nvm use
    npm i
    npm run dev
    
  8. Visit your site on: https://SimpleBlog.com.test:8081

Where to go from here?

We recommend you to check out our Getting Started Guide. Otherwise, you can read up any of the following topics:

Versioning

This project follows semantic versioning.

Bump version in:

  • src/pipit/settings/base.py (APP_VERSION=)
  • frontend/package.json
  • src/Dockerfile

...or just use the bump-version git hook

Style Guide

We follow the django coding style, which is based on PEP8.

Debugging

VS Code

This project is configured for remote debugging using VS Code with the official Python extension. Set VS_CODE_REMOTE_DEBUG=True in docker/config/python.env and restart your container to enable it. You should now be able to attach to the running Django server instance.

PTVSD (Python Tools for Visual Studio debug server) is configured to listen for connections on port 5678.

pdb in Docker

To use pdb you need to start the container with service-ports exposed instead of docker-compose up. This will create a container called <project_prefix>_python_run_1

docker-compose run --rm --service-ports python

Git hooks

We use git-hooks to streamline and automate certain functions, such as version bumping and pre hooks for code validation and tests. If you want to bypass any of them append the --no-verify flag (example: git push --no-verify)

Hook: Bump version

These hooks will automatically bump the application version when using git flow release ...

chmod +x $PWD/.githooks/bump-version.sh
ln -nfs $PWD/.githooks/bump-version.sh .git/hooks/post-flow-release-start
ln -nfs $PWD/.githooks/bump-version.sh .git/hooks/post-flow-hotfix-start

On windows

ln -nfs %cd%/.githooks/bump-version.sh .git/hooks/post-flow-release-start
ln -nfs %cd%/.githooks/bump-version.sh .git/hooks/post-flow-hotfix-start

Hook: Run tests pre push

This hook will run the test suite before every push.

chmod +x $PWD/.githooks/pre-push.sh
ln -nfs $PWD/.githooks/pre-push.sh .git/hooks/pre-push

Hook: Run styleguide validation on commit

chmod +x $PWD/.githooks/pre-commit.sh
ln -nfs $PWD/.githooks/pre-commit.sh .git/hooks/pre-commit

FAQ

How do I sync data from stage/prod?

You can rebuild your application with the latest data dump by running the following

./scripts/stage_to_local.sh

Note: This requires that you have ssh-key based access to the server.

How do I install Docker on MacOS/Windows?

Read the instructions for Mac OS or Windows on docker.com.

How do I run the test suite locally?

docker-compose run --rm python test

How do I run custom manage.py commands?

To run manage.py commands in docker is pretty straightforward, instead of targetting you local machine you just target your python container.

  • Example: Create migrations
docker-compose exec python ./manage.py makemigrations
  • Example: Run migrations
docker-compose exec python ./manage.py migrate

We also have a manage.sh script to make running management commands easier.

./scripts/manage.sh makemigrations

How do I add new python dependencies?

First update your requirements/base.txt, then rebuild your container:

docker-compose stop
docker-compose up --build

How do I install the application on the web server?

This project includes a provision script that sets up anything necessary to run the application (install db, add nginx/uwsgi conf).

ansible-playbook provision.yml -i stages/<stage>.yml

Contributing

Want to contribute? Awesome. Just send a pull request.

License

SimpleBlog is proprietary software. All rights reserved.