psychok7 / django-yadpt-starter

Yet Another Django Project Template skeleton for Django projects
MIT License
28 stars 1 forks source link

Initial Startup script #17

Closed psychok7 closed 7 years ago

psychok7 commented 7 years ago

@pslobo @kapz

We should create a Python startup script that will simplify something like django-admin startproject project_name --template=/your_path/django-project-template-yadpt/minimal/ --extension='py, yml, conf, sh' into startproject project_name --context='/path/file (maybe use a static --template pointing to github).

The extra-context could be the .env file with a mapping like DOMAIN="github.com". The script would then read the file and pass the dictionary to a tool like https://github.com/alfredo/django-startproject-plus in order to override the need variables in the files.

The script will also create the let's encrypt certificates the first time before running anything else and call the following command: docker run -it --rm -v https_certs:/etc/letsencrypt -p 80:80 -p 443:443 palobo/certbot:1.0 certonly -t -n --standalone -d github.com -m test@example.com --agree-tos

psychok7 commented 7 years ago

@pslobo please detail here all the steps that should go into the script and the exact calls made to certbot

pslobo commented 7 years ago

My initial idea for a startup script is based on the following assumptions:

  1. The template can be hosted on github and download when the script is run the first time around;
  2. We won't be running staging and production on the same server

Given those assumptions the steps could be something like:

  1. Invoke the startup script with startproject --[staging|production] project_name
  2. The script then asks for user input, namely DOMAIN, and EMAIL
  3. Performs a git pull of the template for either staging or production
  4. Fill in DOMAIN and EMAIL in production.env or staging.env
  5. Generate the initial certificates by running docker run -it --rm -v {{ project_name }}_https_certs:/etc/letsencrypt -p 80:80 -p 443:443 palobo/certbot:1.0 certonly -t -n --standalone -d {DOMAIN} -m {EMAIL} --agree-tos
  6. Present instructions for next actions maybe.
pslobo commented 7 years ago

I agree that we can remove the .env files. In that case, the startup script will have to populate ${DOMAIN} in ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem; and ssl_certificate_key /etc/letsencrypt/${DOMAIN}/privkey.pem; in letsencrypt.conf

psychok7 commented 7 years ago

@pslobo

The rest seems fine to me.

psychok7 commented 7 years ago

Instead of a simple Python script, i think we should write a django management command since this project needs the user to have django installed

pslobo commented 7 years ago

We either need some way to specify if we're going to run production or staging, mainly because of the https_certs volume. We either have the option to create both i.e. production_https_certs and staging_https_certs or the script needs to know which environment the user is planing on running and just create the right volume.

psychok7 commented 7 years ago

@pslobo --[staging|production] will tell the script the right environment and we create {{ project_name }}_https_certs