Skip to content

Commit

Permalink
chore: more detailed docs (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed Aug 13, 2024
1 parent 62a3e59 commit 1b37388
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 24 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build-rock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ jobs:
- name: Create files required by GoCert
run: |
printf 'key_path: "/etc/config/key.pem"\ncert_path: "/etc/config/cert.pem"\ndb_path: "/etc/config/certs.db"\nport: 3000\npebble_notifications: true\n' > config.yaml
printf 'key_path: "/etc/gocert/config/key.pem"\ncert_path: "/etc/gocert/config/cert.pem"\ndb_path: "/var/lib/gocert/database/certs.db"\nport: 3000\npebble_notifications: true\n' > config.yaml
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 1 -out cert.pem -subj "/CN=githubaction.example"
- name: Run the image
run: |
docker run -d -p 3000:3000 --name gocert gocert:latest
- name: Load config
run: |
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 exec gocert /usr/bin/pebble mkdir -p /etc/gocert/config
docker exec gocert /usr/bin/pebble mkdir -p /var/lib/gocert/database
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
- name: Check if GoCert frontend is loaded
run: |
Expand Down
18 changes: 12 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
41 changes: 30 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

GoCert is a certificate management tool.

## Installation

```bash
docker pull ghcr.io/canonical/gocert:latest
docker run -it ghcr.io/canonical/gocert:latest
```

## Requirements

GoCert requires 3 files to operate:
Expand All @@ -17,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"
```

Expand All @@ -36,9 +29,35 @@ The config file requires the following parameters:
An example config file may look like:

```yaml
key_path: "./key.pem"
cert_path: "./cert.pem"
db_path: "./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
```
## Installation
### From OCI Image
```bash
# Pull the OCI image from github and run it in docker
docker pull ghcr.io/canonical/gocert:latest
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
```

### 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
```
4 changes: 2 additions & 2 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: gocert
base: bare
build-base: [email protected]
version: '0.0.2'
version: '0.0.3'
summary: A certificate management tool
description: |
A certificate management tool.
Expand All @@ -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

Expand Down

0 comments on commit 1b37388

Please sign in to comment.