Skip to content

Commit

Permalink
Feature/docs (#4)
Browse files Browse the repository at this point in the history
* Add hugo

Signed-off-by: Matthew DeVenny <matt@boxboat.com>

* Add netlify

Signed-off-by: Matthew DeVenny <matt@boxboat.com>

* Add initial docs

Signed-off-by: Matthew DeVenny <matt@boxboat.com>
  • Loading branch information
matthewdevenny committed Aug 10, 2021
1 parent 1cd0b87 commit 3905df7
Show file tree
Hide file tree
Showing 172 changed files with 1,518 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# defaults to "--watch" which uses OS native filesystem watching
# set to "--poll=1s" in order to use polling filesystem watching
POLL_ARG="--watch"

# change in order to listen on different port
PORT=1313
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.env
/public

6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docs

## Build Locally

- `docker compose up`
- To change Port or switch to Polling FS Watcher arg, copy `.env.example` to `.env` and modify `.env`
6 changes: 6 additions & 0 deletions docs/archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

5 changes: 5 additions & 0 deletions docs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
baseURL: https://lru-registry.dockhand.dev/
languageCode: en-us
title: dockhand-lru-registry
theme: hugo-geekdocs
3 changes: 3 additions & 0 deletions docs/content/_includes/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
GeekdocHidden: true
---
10 changes: 10 additions & 0 deletions docs/content/_includes/include-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
_**Example page include**_

{{< hint info >}}
**Example Shortcode**\
Shortcode used in an include page.
{{< /hint >}}

| Head 1 | Head 2 | Head 3 |
| ------ | ------ | ------ |
| 1 | 2 | 3 |
21 changes: 21 additions & 0 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Dockhand LRU Registry
description: Dockhand Least Recently Used Registry
geekdocNav: false
geekdocAlign: center
geekdocAnchor: false
---

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD033 -->

<span class="badge-placeholder">[![Build Status](https://img.shields.io/github/workflow/status/boxboat/dockhand-lru-registry/docker)](https://github.com/boxboat/dockhand-lru-registry)</span>
<span class="badge-placeholder">[![GitHub release](https://img.shields.io/github/v/release/boxboat/dockhand-lru-registry)](https://github.com/boxboat/dockhand-lru-registry/releases/latest)</span>
<span class="badge-placeholder">[![GitHub contributors](https://img.shields.io/github/contributors/boxboat/dockhand-lru-registry)](https://github.com/boxboat/dockhand-lru-registry/graphs/contributors)</span>
<span class="badge-placeholder">[![License: APACHE](https://img.shields.io/github/license/boxboat/dockhand-lru-registry)](https://github.com/boxboat/dockhand-lru-registry/blob/main/LICENSE)</span>

<!-- markdownlint-restore -->

The `dockhand-lru-registry` is built using Go and acts as a proxy for [distribution/distribution](https://github.com/distribution/distribution). The lru proxy keeps track of image access and has a schedulable maintenance action. During the maintenance window, the `dockhand-lru-registry` will effectively put the registry in readonly mode, and run garbage collection. If target disk usage has exceeded a configurable threshold it will remove a configurable percentage of the least recently used tags from the registry until usage has dropped back below the target threshold.

{{< button size="large" relref="usage/getting-started/" >}}Getting Started{{< /button >}}
4 changes: 4 additions & 0 deletions docs/content/usage/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Usage
weight: -20
---
159 changes: 159 additions & 0 deletions docs/content/usage/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
---
title: Getting Started
weight: -80
---

This page tells you how to get started with the dockhand-lru-registry, including installation and basic usage.

<!--more-->

{{< toc >}}

## Install

`dockhand-lru-registry` is installed via Helm charts:
- dockhand-lru-registry

The chart can be found in the [dockhand-charts](https://github.com/boxboat/dockhand-charts) repository.

```Shell
# install dockhand-lru-registry
helm repo add dockhand https://dockhand-charts.storage.googleapis.com
helm repo update
helm install --namespace dockhand-lru-registry dockhand/dockhand-lru-registry
```

## Settings

### Helm Chart

#### default `values.yaml`
```yaml
registry:
image:
repository: registry
pullPolicy: IfNotPresent
tag: 2.7.1
conf: |
version: 0.1
log:
fields:
service: registry
storage:
delete:
enabled: true
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
cache:
enabled: true
persistence:
# set to hostPath, emptyDir or pvc
type: pvc
pvc:
#storageClass: "-"
accessMode: ReadWriteOnce
size: 100Gi
hostPath: {}
# path: /mnt/dir
# type: DirectoryOrCreate
emptyDir: {}
#sizeLimit: 20Gi

proxy:
debug: false
port: 3000
cleanSettings:
targetDiskUsage: 80Gi
cleanTagPercentage: 10.0
cron: "0 2 * * *"
timezone: "Local"
# set this to true if the registry isn't sharing a disk
useSeparateDiskCalculation: false
image:
repository: boxboat/dockhand-lru-registry
pullPolicy: IfNotPresent
tag: v0.1.0

service:
type: ClusterIP
port: 3000

ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# nginx.ingress.kubernetes.io/proxy-body-size: "0"
# kubernetes.io/tls-acme: "true"
hosts:
- host: lru-registry.example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

nodeSelector: {}

tolerations: []

affinity: {}
```
#### Considerations
For persistence using a separate dedicated `PersistentVolume` can speed up the maintenance operations by allowing you to set `proxy.cleanSettings.useSeparateDiskCalculation: true`. This will effectively use `statfs` rather than scanning the entire registry directory. Setting `useSeparateDiskCalculation` is not recommended for other storage configurations.

### Direct Use
```shell
dockhand-lru-registry start --help
start the proxy with the provided settings
Usage:
dockhand-lru-registry start [flags]
Flags:
--cert string x509 server certificate
--clean-tags-percentage float percentage of least recently used tags to remove each iteration of a clean cycle until the target-percentage is achieved (default 10)
--cleanup-cron string cron schedule for cleaning up the least recently used tags default is 0:00:00 (default "0 0 * * *")
--db-dir string db directory (default "/var/lib/registry")
-h, --help help for start
--key string x509 server key
--port int (default 3000)
--registry-bin string registry binary (default "/registry/bin/registry")
--registry-conf string registry config (default "/etc/docker/registry/config.yml")
--registry-dir string registry directory (default "/var/lib/registry")
--registry-host string registry host (default "127.0.0.1:5000")
--registry-scheme string registry scheme (default "http")
--separate-disk registry on separate disk or mount - use optimized disk size calculation
--target-disk-usage string target usage of disk for a clean cycle, a scheduled clean cycle will clean tags until this threshold is met (default "50Gi")
--timezone string timezone string to use for scheduling based on the cron-string (default "Local")
--use-forwarded-headers use x-forwarded headers
Global Flags:
--config string config file (default is $HOME/.lru-registry.yaml)
--debug debug output
```
14 changes: 14 additions & 0 deletions docs/content/usage/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Overview
weight: -100
---

## What is the Dockhand LRU Registry?

Dockhand LRU Registry is a proxy that simplifies maintenance of Docker registry by garbage collecting based on a least recently used policy.

## Why Dockhand LRU Registry?
The main use case for this registry is as a build image cache. The trend of building Docker images on Kubernetes clusters necessitates a build cache to ensure optimal build times. In most case you don't want to use your production image registry for this purpose and ideally you want something that requires very little manual intervention. The `dockhand-lru-registry` solves this problem by tracking image tag usage, performing scheduled garbage collection and when necessary will remove the oldest tags first to ensure size constraints are met.

## How it works
`dockhand-lru-registry` acts a proxy for a vanilla open source [Docker Registry](https://github.com/distribution/distribution). As requests push and pull pass through the proxy it updates access time for the image being accessed. Maintenance is schedulable via a familar cron string format. When maintenance is occuring, the proxy will put the registry in readonly mode, run garbage collection, and if necessary remove a percentage of tags to drop the disk usage below the desired threshold.
19 changes: 19 additions & 0 deletions docs/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.7'

services:
hugo:
image: jojomi/hugo:0.85.0
container_name: dockhand-lru-registry-docs
volumes:
- ./:/src
entrypoint:
- hugo
command:
- serve
- --baseURL=http://localhost:${PORT:-1313}/
- --bind=0.0.0.0
- --buildDrafts
- --port=${PORT:-1313}
- "${POLL_ARG:---watch}"
ports:
- "${PORT:-1313}:${PORT:-1313}"
20 changes: 20 additions & 0 deletions docs/themes/hugo-geekdocs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2021 Robert Kaussow

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 changes: 44 additions & 0 deletions docs/themes/hugo-geekdocs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Geekdoc

[![Build Status](https://img.shields.io/drone/build/thegeeklab/hugo-geekdoc?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/hugo-geekdoc)
[![Hugo Version](https://img.shields.io/badge/hugo-0.83-blue.svg)](https://gohugo.io)
[![GitHub release](https://img.shields.io/github/v/release/thegeeklab/hugo-geekdoc)](https://github.com/thegeeklab/hugo-geekdoc/releases/latest)
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/hugo-geekdoc)](https://github.com/thegeeklab/hugo-geekdoc/graphs/contributors)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/hugo-geekdoc)](https://github.com/thegeeklab/hugo-geekdoc/blob/main/LICENSE)

Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme and may not fit the requirements of complex projects. If a more feature-complete theme is required there are a lot of got alternatives out there. You can find a demo and the full documentation at [https://geekdocs.de](https://geekdocs.de).

![Desktop and mobile preview](https://raw.githubusercontent.com/thegeeklab/hugo-geekdoc/main/images/readme.png)

## Build and release process

This theme is subject to a CI driven build and release process common for software development. During the release build, all necessary assets are automatically built by [gulp](https://gulpjs.com/) and bundled in a release tarball. You can download the latest release from the GitHub [release page](https://github.com/thegeeklab/hugo-geekdoc/releases).

Due to the fact that `gulp` is used as pre-processor the theme cannot be used from the main branch by default. If you want to use the theme from a cloned branch instead of a release tarball you'll need to install `gulp` locally and run the default pipeline once to create all required assets.

```Shell
# install required packages from package.json
npm install

# run gulp pipeline to build required assets
npx gulp default
```

See the [Getting Started Guide](https://geekdocs.de/usage/getting-started/) for details about the different setup options.

## Contributors

Special thanks goes to all [contributors](https://github.com/thegeeklab/hugo-geekdoc/graphs/contributors). If you would like to contribute,
please see the [instructions](https://github.com/thegeeklab/hugo-geekdoc/blob/main/CONTRIBUTING.md).

Geekdoc is inspired and partially based on the [hugo-book](https://github.com/alex-shpak/hugo-book) theme, thanks [Alex Shpak](https://github.com/alex-shpak/) for your work.

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/thegeeklab/hugo-geekdoc/blob/main/LICENSE) file for details.

The used SVG icons and generated icon fonts are licensed under the license of the respective icon pack:

- Font Awesome: [CC BY 4.0 License](https://github.com/FortAwesome/Font-Awesome#license)
- IcoMoon Free Pack: [GPL/CC BY 4.0](https://icomoon.io/#icons-icomoon)
- Material Icons: [Apache License 2.0](https://github.com/google/material-design-icons/blob/main/LICENSE)
1 change: 1 addition & 0 deletions docs/themes/hugo-geekdocs/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.16.6
7 changes: 7 additions & 0 deletions docs/themes/hugo-geekdocs/archetypes/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "{{ .Name | humanize | title }}"
weight: 1
# geekdocFlatSection: false
# geekdocToc: 6
# geekdocHidden: false
---
4 changes: 4 additions & 0 deletions docs/themes/hugo-geekdocs/archetypes/posts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
---
Loading

0 comments on commit 3905df7

Please sign in to comment.