- Set up a python virtual environment. E.g. with Anaconda:
conda create -n django-starter python=3.5
source activate django-starter
pip install -r requirements.txt
If psycopg2 installation fails to install, try conda install psycopg2==2.6.2
-
Install
invokeand related libraries in your virtual environment (you can do this in a separate environment if you prefer):
pip install invoke python-dotenv fabric3 pyyaml semver -
Add the project name and details to as well as the virtual environment path to
local.yaml.For Anaconda, if you don't know the path to your virtual environment, you can runwhich pythonfrom within your virtual environment to find your virtual environment path. -
Use
.local.env.exampleas a template to create a.local.envwith the project environmental variables. -
To generate a key use
python -c "import string,random; uni=string.ascii_letters+string.digits+string.punctuation; print repr(''.join([random.SystemRandom().choice(uni) for i in range(random.randint(45,50))]))" -
Start the postgres database:
inv local.compose -c 'up -d postgres' -
Check if Docker is running:
docker psorinv local.compose -c ps -
Migrate database:
inv local.manage migrate -
Start the webserver on port 8000:
inv local.manage 'runserver --insecure'
TODO
- Build the static webserver:
inv k8s.build -c production -v v0.001 - Deploy to Kubernetes Cluster:
inv deploy -c production.yaml -v v0.001.
- Provision the virtual machine:
fab -f ./etc/base_image/server/fabric_tasks.py create:provider='digitalocean' - Add the machine to your SSH config
fab -f ./etc/base_image/server/fabric_tasks.py add
fab -f ./etc/base_image/server/fabric_tasks.py installfab -f ./etc/base_image/server/fabric_tasks.py factory
- Create a Kubernetes Cluster
- Athenticate gcloud:
gcloud auth login
gcloud config set project {project-name} - Connect to kubernetes cluster:
gcloud container clusters get-credentials {cluster-name} --zone us-west1-a --project {project-name} - Letsencrypt SSL setup:
kubectl apply -f etc/k8s/lego/00-namespace.yaml && kubectl apply -f etc/k8s/lego/configmap.yaml && kubectl apply -f etc/k8s/lego/deployment.yaml - Webserver setup:
inv templater production(templater is not yet very smart. you will need to manually configure things like multiple domains)inv setup production - Check the external IP address and setup DNS:
inv ip production