Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ Live data can be requested at any time by using forcing a refresh in their brows

You can see how fresh a pages data is by mousing-over the "unique items" text in the top-center of the page.

## Configuration
## Documentation

YAML-based. See the [configuration guide](docs/config.md).
Thirsting for more? See:

## Deployments

Triage Party is state-less and designed to be deployable anywhere: see the [deployment guide](docs/deploy.md).
* [Configuration guide](docs/config.md)
* [Deployment guide](docs/deploy.md)
* [Persistent cache configuration](docs/persist.md)
45 changes: 45 additions & 0 deletions base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang AS builder
WORKDIR /app

# Build the binary
ENV SRC_DIR=/src/tparty
ENV GO111MODULE=on
RUN mkdir -p ${SRC_DIR}/cmd ${SRC_DIR}/third_party ${SRC_DIR}/pkg ${SRC_DIR}/site /app/third_party /app/site
COPY go.* $SRC_DIR/
COPY cmd ${SRC_DIR}/cmd/
COPY pkg ${SRC_DIR}/pkg/
WORKDIR $SRC_DIR
RUN go mod download
RUN go build cmd/server/main.go

# Setup the site data
FROM gcr.io/distroless/base
COPY --from=builder /src/tparty/main /app/
COPY site /app/site/
COPY third_party /app/third_party/
# Just an example to keep the application from crashing. Supply your own!
COPY examples/generic-project.yaml /app/config/config.yaml

# Useful environment variables:
#
# * GITHUB_TOKEN: Sets GitHub API token
# * CONFIG_PATH: Sets configuration path (defaults to "/app/config/config.yaml")
# * PORT: Sets HTTP listening port (defaults to 8080)
#
# For other environment variables, see:
# https://github.com/google/triage-party/blob/master/docs/deploy.md
CMD ["/app/main", "--min-refresh=30s", "--max-refresh=8m", "--site=/app/site", "--3p=/app/third_party"]
65 changes: 26 additions & 39 deletions docs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,38 @@ While Triage Party primarily uses flags for deployment configuration, several se

### Docker

The simple Docker deployment is setup for easy cache persistence from disk:

```shell
docker build --tag=tp --build-arg CFG=examples/generic-project.yaml .
docker run -e GITHUB_TOKEN=<your token> -p 8080:8080 tp
```

### Google Cloud Build
### Kubernetes

```shell
gcloud builds submit . --substitutions=_CFG=path/to/my/config.yaml
```
See [examples/manifests](../../examples/manifests)

The built image is tagged with `gcr.io/$PROJECT_ID/triage-party:latest`. See the [cloudbuild.yaml](../cloudbuild.yaml) file for more options.
Add the GitHub token as a secret:

### Google Cloud Run
`kubectl create secret generic triage-party-github-token -n triage-party --from-file=token=$HOME/.github-token`

Triage Party was designed to run with Google Cloud Run. That said, Google Cloud Run agressively spins down containers which are not serving incoming requests, which means:
Create a namespace:

* Results may sometimes be stale (a warning will be shown in the UI)
* For faster start-up, you'll want to configure an external persistent cache, such as Cloud SQL
`kubectl apply -f examples/manifests/namespace.yaml`

Add the configuration as a ConfigMap, and setup a NodePort:

`kubectl apply -f ./examples/manifests`

For faster Triage Party restarts, configure a [persistent cache](persistent.md).

If you are deploying to minikube, this will open Triage Party up in your local web browser:

`minikube service triage-party -n triage-party`

### Google Cloud Run

Here is a command-line example that deploys to Cloud Run with Cloud SQL persistence:
Triage Party was designed to run well with Google Cloud Run. Here is an example command-line to deploy against Cloud Run with a Cloud SQL hosted [persistent cache](persist.md).

```shell
gcloud beta run deploy "${SERVICE_NAME}" \
Expand All @@ -48,34 +59,10 @@ gcloud beta run deploy "${SERVICE_NAME}" \

For a real-world example deployment script, see [examples/minikube-deploy.sh](examples/minikube-deploy.sh)

### Kubernetes

See [examples/generic-kubernetes.yaml](examples/generic-kubernetes.yaml)

For faster start-up, you will want to persist cache externally to a PersistentVolume or database in case a pod is rescheduled.

## Configuring Persistence

Triage Party uses an in-memory cache with an optional persistence layer to decrease the load on GitHub API. It uses disk by default, but can be configured to use an external databasee. To configure it, use:

* Backend type: `--persist-backend` flag or `PERSIST_BACKEND` environment variable
* Backend path: `--persist-path` flag or `PERSIST_PATH` environment flag.

Supported backends include:

* `disk` - useful for development or small installations
* `mysql` - useful for all installations
* `postgres` - supports both PostgreSQL and CockroachDB
* `cloudsql` - useful for Google Cloud installations
* `memory` - no persistence

Examples flag settings:
### Google Cloud Build

* **Custom disk path**: `--persist-path=/var/tmp/tp`
* **MySQL**: `--persist-backend=mysql --persist-path="user:password@tcp(127.0.0.1:3306)/tp"`
* **PostgreSQL**: `--persist-backend=postgres --persist-path="dbname=tp"`
* **CockroachDB**: `--persist-backend=postgres postgresql://[email protected]:26257?sslmode=disable`
* **CloudSQL - MySQL**: `--persist-backend=cloudsql --persist-path="user:password@tcp(project/us-central1/triage-party)/db"`
* **CloudSQL - Postgres**: `--persist-backend=cloudsql --persist-path="host=projectname:us-central1:dbname user=postgres password=pw"`
```shell
gcloud builds submit . --substitutions=_CFG=path/to/my/config.yaml
```

NOTE: Local development with CloudSQL backends may require setting up [GOOGLE_APPLICATION_CREDENTIALS](https://cloud.google.com/docs/authentication/getting-started)
The built image is tagged with `gcr.io/$PROJECT_ID/triage-party:latest`. See the [cloudbuild.yaml](../cloudbuild.yaml) file for more options.
53 changes: 53 additions & 0 deletions docs/persist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Triage Party: Persistent Cache

Triage Party uses an in-memory cache with an optional persistence layer to
significantly speed up startup, as well as decrease load on the GitHub API.

The persistence layer is only read during startup, and is written to
only ocassionally. To configure persistence, use:

* Type: `--persist-backend` flag or `PERSIST_BACKEND` environment variable
* Path: `--persist-path` flag or `PERSIST_PATH` environment flag.

## Disk

Triage Party uses a disk backend by default. It's battle-tested, and ideal for development and smaller deployments. It is not a good match for environments like Google Cloud Run, which do not have persistent storage available.

If `--persist-path` is unset, Triage Party will search for the following directories, choosing the first one which exists.

* `/app/pcache` (production)
* `./pcache`, `../pcache`, `../../pcache` (dev)
* `<UserCacheDir>/pcache` (fallback)

## Google CloudSQL

Triage Party has built-in support for using Google Cloud SQL, using either the MySQL or Postgres backend:

* **MySQL**: `--persist-backend=cloudsql --persist-path="user:password@tcp(project/us-central1/triage-party)/db"`
* **Postgres**: `--persist-backend=cloudsql --persist-path="host=projectname:us-central1:dbname user=postgres password=pw"`

For local development, you will need to setup [GOOGLE_APPLICATION_CREDENTIALS](https://cloud.google.com/docs/authentication/getting-started).

## MySQL or MariaDB

Example usage:

`--persist-backend=mysql --persist-path="user:password@tcp(127.0.0.1:3306)/tp"`

## PostgreSQL

Tested with Postgres 11 & 12.2. Example usage:

`--persist-backend=postgres --persist-path="dbname=tp"`

## CockroachDB

CockroachDB has a Postgres front-end, which makes it easy to support. Here's an example, tested with v19.2.6:

`--persist-backend=postgres postgresql://[email protected]:26257?sslmode=disable`

## Memory

If no reliable storage is available, this will disable the persistent cache:

`--persist-backend=memory`
Loading