Skip to content

Latest commit

 

History

History
132 lines (92 loc) · 2.4 KB

CONTRIBUTING.md

File metadata and controls

132 lines (92 loc) · 2.4 KB

Contributing

Notary is an open source project that warmly welcomes community contributions, suggestions, fixes, and constructive feedback.

Getting Started

This tutorial guides you through setting up a development environment for Notary.

After going through these steps, you will have a general idea of how to build and run Notary.

Prerequisites

Install Go:

sudo snap install go --classic

Install NodeJS:

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt update
sudo apt install nodejs

Clone the repository:

[email protected]:canonical/notary.git

Build Notary

Install the npm dependencies:

npm install --prefix ui 

Build the frontend:

npm run build --prefix ui

Build the Go binary:

go build -o notary cmd/notary/main.go

Run Notary

Create a certificate and private key:

openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 1 -out cert.pem -subj "/CN=example.com"

Create a notary.yaml file with the following content:

key_path:  "key.pem"
cert_path: "cert.pem"
db_path: "certs.db"
port: 3000
pebble_notifications: false

Run Notary:

./notary -config notary.yaml

Access the Notary UI at https://localhost:3000.

How-to Guides

Run Unit Tests

Run go unit tests by running:

go test ./...

Run frontend vitest test suite by running:

npm run test --prefix ui

Run Lint checks

Run the linter for golang by running:

golangci-lint run ./...

Run the linter for typescript by running:

npm run lint

Create a container Image

Install rockcraft:

sudo snap install rockcraft --classic

Build the container image:

rockcraft pack -v

Copy the container image to the docker daemon:

version=$(yq '.version' rockcraft.yaml)
sudo rockcraft.skopeo --insecure-policy copy oci-archive:notary_${version}_amd64.rock docker-daemon:notary:${version}

Run the container image:

docker run notary:${version}

Reference