Onebook is a website allowing artists to publish their work and create their online "book".
Before running the command
: The database must be started and the env variables must be defined in the .env file.
npm run dev
Create a .env file and fill it with the following variables:
DB_URL
The database url to connect to.
Example: postgres://postgres:<password>@127.0.0.1:5432/postgres
JWT_SECRET_TOKEN
The secret token used to sign the JWT token.
CLOUDINARY_CLOUD_NAME
Your cloudinary cloud name.
CLOUDINARY_API_KEY
Your cloudinary api key.
CLOUDINARY_API_SECRET
Your cloudinary api secret.
- Kubernetes distribution (examples: k3s or minikube)
- Kubectl CLI
- Docker
In the following commands, only k3s is used.
- create a new k3d cluster named onebook and a dev namespace
k3d cluster create onebook
kubectl create namespace dev
- Build and test the onebook-backend image with Docker
docker build -t onebook-backend:dev .
docker run --rm --name onebook-backend -p 4000:4000 onebook-backend:dev
# access the application
curl http://localhost:4000
docker stop onebook-backend
- Pull postgres image for the database
docker pull postgres:latest
- Add your customs images to the k3d cluster
k3d image import onebook-backend:dev -c onebook
k3d image import postgres:latest -c onebook
- Deploy the application
Before apply the infra-as-code files
: fill all <variables> in Deployment files.
# start the database first
kubectl apply -f infra-as-code/DB_Deployment.yaml
kubectl apply -f infra-as-code/
# verify the deployment
kubectl get deployments -n dev
# verify the service and get its external IP
kubectl get services -n dev
# access the application
curl http://<service-external-ip>:4000
To clean the Kubernetes dev namespace:
kubectl delete -f infra-as-code/
To remove the Kubernetes dev namespace:
kubectl delete namespace dev