diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ff020a..28e3350 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Contributing ## Getting Started +You can build and run the program by following these steps: 1. Install Go and Nodejs 2. Fork the repository on GitHub @@ -11,31 +12,36 @@ 7. Run the project: `gocert -config config.yaml` Commands assume you're running them from the top level git repo directory + ## Testing ### Unit Tests -Go: +Run go unit tests by running: ```bash go test ./... ``` -Frontend: + +Run frontend vitest test suite by running: ```bash -npm run test +npm run test --prefix ui ``` ### Lint -Go: +Run the linter for golang by running: ```bash golangci-lint run ./... ``` -Frontend: +Run the linter for typescript by running: ```bash npm run lint ``` -## Container image +## Creating the Container Image + +We use rockcraft to create OCI images for use in container technologies like docker. +You can create the container and import it into docker by running: ```bash rockcraft pack -v diff --git a/README.md b/README.md index c914d67..31b83eb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ GoCert requires 3 files to operate: * A YAML config file with the required parameters You can generate the cert and the associated key by running: -``` +```bash openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 1 -out cert.pem -subj "/CN=example.com" ``` @@ -29,9 +29,9 @@ The config file requires the following parameters: An example config file may look like: ```yaml -key_path: "/gocert/key.pem" -cert_path: "/gocert/cert.pem" -db_path: "/gocert/certs.db" +key_path: "/etc/gocert/config/key.pem" +cert_path: "/etc/gocert/config/cert.pem" +db_path: "/var/lib/gocert/database/certs.db" port: 3000 pebble_notifications: true ``` @@ -40,20 +40,24 @@ pebble_notifications: true ### From OCI Image -You can run GoCert in docker by doing: - ```bash +# Pull the OCI image from github and run it in docker docker pull ghcr.io/canonical/gocert:latest -docker run -it ghcr.io/canonical/gocert:latest -``` - -You will then need to push the 3 required files before it will launch successfully. You can do this by -```bash -docker exec gocert /usr/bin/pebble mkdir /etc/config -docker cp key.pem gocert:/etc/config/key.pem -docker cp cert.pem gocert:/etc/config/cert.pem -docker cp config.yaml gocert:/etc/config/config.yaml +docker run -d --name gocert -p 3000:3000 ghcr.io/canonical/gocert:latest +# Push the 3 required files and restart the workload +docker exec gocert /usr/bin/pebble mkdir -p /etc/gocert/config +docker cp key.pem gocert:/etc/gocert/config/key.pem +docker cp cert.pem gocert:/etc/gocert/config/cert.pem +docker cp config.yaml gocert:/etc/gocert/config/config.yaml docker restart gocert ``` -### Build from Source \ No newline at end of file +### From Source + +go and npm CLI tools need to be installed in order to build gocert from source. +You will need to build the frontend first, and then install gocert with Go. + +```bash +npm install --prefix ui && npm run build --prefix ui && go install ./... +gocert -config ./config.yaml +``` \ No newline at end of file diff --git a/rockcraft.yaml b/rockcraft.yaml index 1732ec5..61ac6ef 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,7 +1,7 @@ name: gocert base: bare build-base: ubuntu@24.04 -version: '0.0.2' +version: '0.0.3' summary: A certificate management tool description: | A certificate management tool. @@ -12,7 +12,7 @@ platforms: services: gocert: - command: gocert [ -config /etc/config/config.yaml ] + command: gocert [ -config /etc/gocert/config/config.yaml ] override: replace startup: enabled