This repository contains the code for both https://www.aphiria.com and https://api.aphiria.com.
First, install Docker. Then, run ./install.sh
to install the other dependencies:
- kubectl
- Minikube
- Helm
- Helmfile
- Terraform
- doctl
Note: You may have to run
chmod +x ./install.sh
to make the script executable.
Add the following to your host file:
127.0.0.1 aphiria.com
127.0.0.1 api.aphiria.com
127.0.0.1 www.aphiria.com
docker login -u <username>
Note: If you get an error trying to save your credentials, run
rm ~/.docker/config.json
.
kubectl lets you configure multiple clusters (eg your DigitalOcean and minikube clusters). To do so, download the kubeconfig file from the DigitalOcean cluster.
Note: If using WSL2, copy it to your ~/ directory and name it digitalocean.yml.
export KUBECONFIG=~/.kube/config:~/digitalocean.yml
kubectl config view --flatten > ~/combined.yml
cp ~/combined.yml ~/.kube/config
Verify that you see multiple context by running
kubectl config get-contexts
To switch contexts, simply run
kubectl config use-context DESIRED_CONTEXT_NAME
You must build your Docker images before you can run the application. If using Minikube, first configure it to use the Docker registry contained within:
eval $(minikube -p minikube docker-env)
Then, build the images:
docker build -t aphiria.com-build -f ./infrastructure/docker/build/Dockerfile .
docker build -t aphiria.com-api -f ./infrastructure/docker/runtime/api/Dockerfile .
docker build -t aphiria.com-web -f ./infrastructure/docker/runtime/web/Dockerfile .
Get Minikube running:
minikube start
minikube dashboard
Note: If you're running as the root user, run
minikube start --force
instead.
In another console terminal, create a tunnel to be able to connect to Minikube:
minikube tunnel
Use Helmfile to install the required Helm charts:
helmfile -f ./infrastructure/kubernetes/base/helmfile.yml repos
helmfile -f ./infrastructure/kubernetes/base/helmfile.yml sync
Apply the Kubernetes dev manifest using Kustomize:
kubectl apply -k ./infrastructure/kubernetes/environments/dev
You should now be able to hit https://www.aphiria.com in your browser. You will get a TLS certificate error since we're using a self-signed certificate locally.
Note: If using Chrome, type
thisisunsafe
to accept the self-signed certificate. Likewise, you'll have to do the same for the API, which you can do by visiting https://api.aphiria.com/docs/search?query=foo and typingthisisunsafe
.