Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: example deployment for kubernetes #754

Merged
merged 3 commits into from Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
124 changes: 118 additions & 6 deletions docs/Installation.md
Expand Up @@ -2,13 +2,18 @@ There are several installation methods available :

<!-- TOC -->

- [Using Precompiled Binary](#using-precompiled-binary)
- [Building From Source](#building-from-source)
- [Using Docker Image](#using-docker-image)
- [Supported](#supported)
- [Using Precompiled Binary](#using-precompiled-binary)
- [Building From Source](#building-from-source)
- [Using Docker Image](#using-docker-image)
- [Community provided](#community-provided)
- [Using Kubernetes manifests](#using-kubernetes-manifests)

<!-- /TOC -->

## Using Precompiled Binary
## Supported

### Using Precompiled Binary

Download the latest version of `shiori` from [the release page](https://github.com/go-shiori/shiori/releases/latest), then put it in your `PATH`.

Expand All @@ -28,15 +33,15 @@ source $HOME/.profile

On Windows, you can simply set the `PATH` by using the advanced system settings.

## Building From Source
### Building From Source

Shiori uses Go module so make sure you have version of `go >= 1.14.1` installed, then run:

```
go get -u -v github.com/go-shiori/shiori
```

## Using Docker Image
### Using Docker Image

To use Docker image, you can pull the latest automated build from Docker Hub :

Expand All @@ -49,3 +54,110 @@ If you want to build the Docker image on your own, Shiori already has its [Docke
```
docker build -t shiori .
```

## Community provided

Below this there are other ways to deploy Shiori which are not supported by the team but were provided by the community to help others have a starting point.

### Using Kubernetes manifests

If you're self-hosting with a Kubernetes cluster, here are manifest files that
you can use to deploy Shiori:

`deploy.yaml`:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: shiori
labels:
app: shiori
spec:
replicas: 1
selector:
matchLabels:
app: shiori
template:
metadata:
labels:
app: shiori
spec:
volumes:
- name: app
hostPath:
path: /path/to/data/dir
containers:
- name: shiori
image: ghcr.io/go-shiori/shiori:latest
command: ["/usr/bin/shiori", "serve", "--webroot", "/shiori"]
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /srv/shiori
name: app
env:
- name: SHIORI_DIR
value: /srv/shiori
- name: HTTP_ROOT_PATH
value: "/shiori"
```

Here we are using a local directory to persist Shiori's data. You will need
to replace `/path/to/data/dir` with the path to the directory where you want
to keep your data. Since we haven't configured a database in particular,
Shiori will use SQLite. I don't think Postgres or MySQL is worth it for
such an app, but that's up to you. If you decide to use SQLite, I strongly
suggest to keep `replicas` set to 1 since SQLite usually allows at most
one writer to proceed concurrently.

Also, not that we're serving the app on the `/shiori` suffix. This is
only necessary if you want to access Shiori with an URL that looks like:
`http://your_domain_name/shiori`. This is also why we override the container's
command: to pass the webroot. If you want to use such suffix, you'll probably
need to deploy an ingress as well:

`ingress.yaml`:

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shiori
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /shiori
pathType: Prefix
backend:
service:
name: shiori
port:
number: 8080
```

Finally, here is the service's config:

`service.yaml`

```yaml
apiVersion: v1
kind: Service
metadata:
name: shiori
spec:
type: NodePort
selector:
app: shiori
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 32654
```

I'm using the NodePort type for the service so I can access it easily on
my local network, but it's not necessary if you setup the ingress.