GoData

Simple and fast server that serves the NFTs written in Go.
Usage
go run ./... --port [port]
Enpoints:
GET /:tokenId to get a metadata entry
POST /:tokenId
to add an entry (requires Authorization: [METADATA_API_KEY] header)
GET / for healthchecks, returns empty 200 OK
Under the hood
Server uses Gin (gin-gonic) framework for serving metadata stored in Redis
database as JSON. Deployment is onto a cluster provisioned from Linode. The
format complies to the opensea.io metadata standards and employs NGINX ingress
with TLS certificates from lets-encrypt through cert-manager.io. The API packed
into a docker image of piotrostr/metadata is deployed aside a Redis image.
Deployment
-
The configuration file config.json is required for production deployments.
| field |
value |
name |
Collection name |
description |
Description |
external_url |
GS/S3/.. URL for placholder image |
placeholder_image |
IPFS url for placeholder image |
-
Redis Database is also required, without it the data endpoints return
nil.
Note: The steps are user-specific since there is a number of variables like
certificate issuer email etc, the steps are more of guidelines rather than
walkthrough-tutorial or local setup.
Provision the cluster
cd terraform/linode && terraform apply
terraform output kubeconfig | jq -r '@base64d' > ~/.kube/lke.yaml
export KUBECONFIG=~/.kube/lke.yaml
cd -
Deploy to the cluster
-
Install ingress
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace
-
To get the IPv4 of the Ingress
kubectl get services \
--namespace ingress-nginx \
-o wide \
-w \
ingress-nginx-controller
-
Add A-Record to the domain from the Ingress manifest (in this case
metadata.smplvserse.xyz) pointing to the IPv4 of the Ingress
-
Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
-
Add secret (required env var for the metadata api)
kubectl create secret generic metadata-api-key --from-literal METADATA_API_KEY=[secret]
-
Apply the configuration
skaffold apply manifest.yaml
I prefer skaffold to kubectl for applying deployments as it waits
for them to stabilise and exits with error code 1 in case any container
fails.