Skip to content

Commit

Permalink
💚 ci: deployments added
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
  • Loading branch information
mhkarimi1383 committed Jun 8, 2024
1 parent d09d3d7 commit a5bd102
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 57 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/image-publish.yaml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
name: publish

on:
push:
tags:
- "*"
branches:
- "*"

env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io

jobs:
build:
name: Build Container Image
runs-on: ubuntu-latest
continue-on-error: false

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3.3.0

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: image_name_generator
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_NAME }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ steps.image_name_generator.outputs.lowercase }}

- name: Build and push Docker image
id: build-and-push-release
uses: docker/build-push-action@v5.3.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.image_name_generator.outputs.lowercase }}:latest
${{ env.REGISTRY }}/${{ steps.image_name_generator.outputs.lowercase }}:${{ github.ref_name }}
deploy:
name: Deploy to parminpaas.ir
needs: build
runs-on: ubuntu-latest
continue-on-error: false

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}

- uses: helmwave/setup-action@v0.2.0
name: Install helmwave
with:
version: "0.36.3"

- name: Templating helmwave.yml.tpl
working-directory: "./deployments/kubernetes"
run: "helmwave yml"
env:
CERT_MANAGER_CLUSTER_ISSUER: ${{ secrets.CERT_MANAGER_CLUSTER_ISSUER }}
DOMAIN: ${{ secrets.DOMAIN }}
INGRESS_CLASS: ${{ secrets.INGRESS_CLASS }}
VERSION: ${{ github.ref_name }}

- name: Plan
working-directory: "./deployments/kubernetes"
run: helmwave build
env:
CERT_MANAGER_CLUSTER_ISSUER: ${{ secrets.CERT_MANAGER_CLUSTER_ISSUER }}
DOMAIN: ${{ secrets.DOMAIN }}
INGRESS_CLASS: ${{ secrets.INGRESS_CLASS }}
VERSION: ${{ github.ref_name }}

- name: Deploy
working-directory: "./deployments/kubernetes"
run: helmwave up --kubedog --progress
env:
CERT_MANAGER_CLUSTER_ISSUER: ${{ secrets.CERT_MANAGER_CLUSTER_ISSUER }}
DOMAIN: ${{ secrets.DOMAIN }}
INGRESS_CLASS: ${{ secrets.INGRESS_CLASS }}
VERSION: ${{ github.ref_name }}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
* Object actions (Upload, Download, Remove, etc.)
* Dark/Light Mode :)

## Deployment

Check out [deployments](./deployments/README.md)

## TODO

* [ ] Pagination
* [ ] Save credentials in browser
* [ ] Creating and Using more reusable components (specially Modals in page)
* [ ] More Docs (Screenshot, Deployment)
* [ ] More Docs (Screenshot, Deployment) [WIP]

## Contributing

Expand Down
6 changes: 6 additions & 0 deletions deployments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Deployments

Currently we are providing Docker Compose and Kubernetes (Helmwave) Deployment methods to self-host this project.

* [Kubernetes](./kubernetes/README.md)
* [Docker Compose](./docker/README.md)
18 changes: 18 additions & 0 deletions deployments/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Docker Compose Deployment

## Requirements

* Docker
* Docker Compose CLI Plugin
* Docker Daemon Access

## How to run

Simple run

```shell
docker compose pull
docker compose up -d
```

Open your browser at <http://127.0.0.1:3000>
23 changes: 23 additions & 0 deletions deployments/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: storage-browser
services:
storage-browser:
image: ghcr.io/parmincloud/storage-browser:main
container_name: storage-browser
restart: always
healthcheck:
test: ["CMD-SHELL", "bash", "-c", "nc -vz 127.0.0.1 3000"]
interval: 5s
timeout: 1s
retries: 2
start_period: 1s
ports:
- target: 3000
published: 3000
protocol: tcp
mode: ingress
name: http
host_ip: 0.0.0.0

networks:
default:
name: storage-browser
2 changes: 2 additions & 0 deletions deployments/kubernetes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.helmwave/
helmwave.yml
32 changes: 32 additions & 0 deletions deployments/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Kubernetes Deployment

Self Host Storage Browser in K8s

Powered By Helmwave, Stakater Application helm chart and Bedag Raw helm chart (for kong configurations)

## Requirements

* [Helmwave](https://helmwave.app)
* Ability to create namespace or having full access to namespace (named `storage-browser`)

## How to run

Set env vars like below

```shell
INGRESS_CLASS=nginx # Optional, name of the ingressClass special configs and annotations will set and applied if one of nginx or kong set
VERSION=main # Required, Branch name or tag
CERT_MANAGER_CLUSTER_ISSUER=http-issuer # Optional, name of cert-manager cluster-issuer (Required if you want HTTPS support)
DOMAIN=storage-browser.example.com # Required, Domain name of the deployment
```

Then run

```shell
# Template helmwave configuration
helmwave yml
# Build chart(s) information (values, etc.)
helmwave build
# Bring it Up
helmwave up --kubedog --progress
```
51 changes: 51 additions & 0 deletions deployments/kubernetes/helmwave.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 0.36.3
project: StorageBrowser

{{- $ingressClass := env "INGRESS_CLASS" }}

repositories:
- name: stakater
url: https://stakater.github.io/stakater-charts
{{- if eq $ingressClass "kong" }}
- name: bedag
url: https://bedag.github.io/helm-charts
{{- end }}

releases:
{{- if eq $ingressClass "kong" }}
- name: storage-browser-kong
namespace: storage-browser
description: Kong configurations for ParminCloud S3 Object Storage Browser
max_history: 3
allow_failure: false
create_namespace: true
reuse_values: false
wait: true
wait_for_jobs: true
chart:
name: bedag/raw
values:
- src: values.kong.yaml
strict: true
{{- end }}

- name: storage-browser
namespace: storage-browser
description: ParminCloud S3 Object Storage Browser
max_history: 3
allow_failure: false
create_namespace: true
reuse_values: false
wait: true
wait_for_jobs: true
chart:
name: stakater/application
values:
- src: ./values.yaml
strict: true
renderer: sprig
{{- if eq $ingressClass "kong" }}
depends_on:
- name: storage-browser-kong
optional: false
{{- end }}
25 changes: 25 additions & 0 deletions deployments/kubernetes/values.kong.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resources:
- apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: bot-detection
plugin: bot-detection
config: {}
- apiVersion: configuration.konghq.com/v1beta1
kind: KongUpstreamPolicy
metadata:
name: storage-browser
spec:
algorithm: least-connections
healthchecks:
active:
type: http
httpPath: /
healthy:
httpStatuses:
- 200
interval: 5
successes: 2
unhealthy:
httpFailures: 1
interval: 5
Loading

0 comments on commit a5bd102

Please sign in to comment.