This is my homepage/blog.
MySQL Client
You need to have a mysql client installed. Usually that means installing the right package.
$ apt-get install -y libmysqlclient-dev
Create a virtualenv
$ mkvirtualenv homepage
Install the development requirements
$ python setup.py develop
Run initial migrations
$ DEBUG=true homepage migrate
Create an "admin" superuser with password "admin"
$ DEBUG=true homepage createsuperuser
Run the development server in debug mode.
$ DEBUG=true python manage.py runserver
You can also run the production webserver in debug mode but it won't reload when code is updated.
$ DEBUG=true homepage start
This application is deployed on Google Container Engine, however, any Kubernetes cluster would do.
Create secrets for the homepage app. The secrets file should something like the file below. Each value should be encoded in base64. See the secrets doc for more info. Save the file to homepage-secrets.yaml.
apiVersion: v1
kind: Secret
metadata:
name: homepage-secret
data:
secret-key: ...
disqus-api-key: ...
disqus-website-shortname: ...
db-user: ...
db-password: ...
Deploy the secrets to the cluster.
$ kubectl apply -f homepage-secrets.yaml
Building a Docker image should be straight-forward. Give the image a tag that matches the repository url you want and give it a version label.
$ docker build -t gcr.io/ianlewis-org/homepage:<VERSION> .
This app depends on MySQL so you need to deploy that app first.
Deploy the homepage app.
$ kustomize build kubernetes/staging | kubectl apply -f -
Migrations are run by running a Job using the Kubernetes Jobs API.
$ kubectl apply -f kubernetes/extras/migrate.yaml
Creating superusers is done by running a Job using the Kubernetes Jobs API.
$ kubectl apply -f kubernetes/extras/createsuperuser-job.yaml
This will create a superuser with the username and password "admin". You will need to login and update the password of this user immediately after creation.