Docker registry driver for powergate
This project implements the docker registry storage driver for powergate. This driver can be used to configure a registry server to store images into powergate's tiered storage. (Hot (IPFS) + Cold (Filecoin).
This project uses the Powergate Go API client to implement a storage driver interface for docker. The powergate API for storing data is a key/value interface, whereas the docker storage driver implements a filesystem-like interface. In order to use powergate, we need to translate the filesystem ops to key/value type ops. In order to achieve this, I have implemented a local DB.
Using a local DB, I maintain the filesystem information and push the actual blobs to powergate. This local DB is called a "manifest". I have used another project which provides a simple KV interface over ipfs/go-datastore. Currently, this DB has a separate file that is used for badger, but this could potentially be integrated with IPFS itself in the future.
Any client that needs to access the registry will need this manifest file. The manifest file itself can be posted to powergate using an additional command. This can then give us a CID to initialize instead of the entire file. I did not have time to implement this part.
The local DB object is called an Inode, which looks like
type PowInode struct {
Name string
Hash string
JobID string
Dir bool
Sz int64
Children []string
Created int64
Updated int64
}
This object can represent a directory, in which case we will have children populated. Otherwise its a file, in which case, it will have the IPFS hash and powergate cold storage job ID populated.
For filesystem ops that don't manipulate the actual file content, all the operations are performed on this manifest DB. If we do backup of manifest onto IPFS, we will need to update it whenever anything changes.
Rest is just using the Powergate client to add/remove/replace the data. The following PR shows all the code changes done for this:
https://github.com/aloknerurkar/distribution/pull/1
The powdocker directory contains a modified version of powergate docker scripts which I have used. Added the registry image as well as change port nos etc.
Main parts to look:
/registry/storage/driver/powergate => Implementation
/cmd/registry/config-dev.yml => Configuring the powergate driver on the docker image
/powdocker/docker-compose-localnet.yaml => Adding powdocker image