How to use a custom dockerfile tutorial
Prerequisites:
- A working station, e.g., a laptop.
- Juju and Microk8s installed
- Docker snap installed
For practicality, we strongly advice you to enable microk8s’ registry to push docker images to a local registry (the tutorial will be made with this registry), and you’ll also need ingress to be enabled for this tutorial:
microk8s enable ingress registry
Lets deploy anbox-cloud.io page on a local charm.
First, you need to download the anbox-cloud repo by executing the next command:
git clone https://github.com/canonical/anbox-cloud.io.git
Then, change the current directory to the repo’s folder and execute the following to build the docker image and push it to the registry:
DOCKER_BUILDKIT=1 docker build . -t localhost:32000/anbox:latest -f Dockerfile --no-cache
docker push localhost:32000/anbox:latest
Then you should add a model to your k8s-controller in juju and deploy both gunicorn-k8s and nginx-ingress-integrator supplying some extra parameters:
juju add-model gunicorndepl
juju deploy gunicorn-k8s \
--resource gunicorn-image='localhost:32000/anbox:latest' \
--config startup_command='talisker.gunicorn.gevent webapp.app:app --bind 0.0.0.0:8080 --worker-class gevent --name talisman-`hostname`' \
--config environment='SECRET_KEY: 12345'
juju deploy nginx-ingress-integrator ingress
juju relate gunicorn-k8s ingress
Then, edit your /etc/hosts
file, adding the following line:
{Your ingress IP} anbox-local
If you don’t know your Ingress IP, you can use the following command to learn it:
microk8s kubectl get pods -n ingress -o wide
This way, when you browse anbox-local it will resolve to your ingress service IP. Now, browse to http://anbox-local and you’ll see the web page deployed.