metadata

module
v0.0.0-...-bb1d636 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2022 License: MIT

README

GoData

Go Report Card codecov CICD

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

  1. 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
  2. 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
  1. Install ingress

    helm upgrade --install ingress-nginx ingress-nginx \
      --repo https://kubernetes.github.io/ingress-nginx \
      --namespace ingress-nginx --create-namespace
    
  2. To get the IPv4 of the Ingress

    kubectl get services \
      --namespace ingress-nginx \
      -o wide \
      -w \
      ingress-nginx-controller
    
  3. Add A-Record to the domain from the Ingress manifest (in this case metadata.smplvserse.xyz) pointing to the IPv4 of the Ingress

  4. Install cert-manager

    kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
    
  5. Add secret (required env var for the metadata api)

    kubectl create secret generic metadata-api-key --from-literal METADATA_API_KEY=[secret]
    
  6. 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.

Directories

Path Synopsis
cmd
app command
pkg
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL