Skip to content

Commit 1e37b1d

Browse files
authored
Merge pull request #1 from toggle-corp/feature/react-serve
Add chart for react-serve
2 parents a9e9c76 + a82fa1e commit 1e37b1d

File tree

12 files changed

+311
-0
lines changed

12 files changed

+311
-0
lines changed

.github/workflows/helm-publish.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Lint/Builds/Push Helm charts to Github Registry
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'toggle/**'
10+
11+
permissions:
12+
packages: write
13+
14+
jobs:
15+
build:
16+
name: Publish Helm
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
include:
21+
- chart: react-serve
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Install Helm
28+
uses: azure/setup-helm@v3
29+
30+
# Lint/Build
31+
- name: Helm dependency
32+
working-directory: ./toggle/${{ matrix.chart }}
33+
run: |
34+
yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./Chart.lock | sh --
35+
helm dependency build ./
36+
37+
- name: 🐳 Helm lint
38+
working-directory: ./toggle/${{ matrix.chart }}
39+
run: helm lint ./ --values ./values-test.yaml
40+
41+
- name: 🐳 Helm template
42+
working-directory: ./toggle/${{ matrix.chart }}
43+
run: helm template ./ --values ./values-test.yaml
44+
45+
# Publish
46+
- name: Login to GitHub Container Registry
47+
uses: docker/login-action@v3
48+
if: ${{ github.event_name == 'push' }}
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Package Helm Chart
55+
working-directory: ./toggle/${{ matrix.chart }}
56+
if: ${{ github.event_name == 'push' }}
57+
run: |
58+
helm package ./ -d .helm-charts
59+
60+
- name: Push Helm Chart
61+
working-directory: ./toggle/${{ matrix.chart }}
62+
if: ${{ github.event_name == 'push' }}
63+
env:
64+
OCI_REPO: oci://ghcr.io/${{ github.repository }}
65+
run: |
66+
OCI_REPO=$(echo $OCI_REPO | tr '[:upper:]' '[:lower:]')
67+
PACKAGE_FILE=$(ls .helm-charts/*.tgz | head -n 1)
68+
echo "## Helm Chart" >> $GITHUB_STEP_SUMMARY
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo "Helm push output:" >> $GITHUB_STEP_SUMMARY
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
echo '```bash' >> $GITHUB_STEP_SUMMARY
73+
helm push "$PACKAGE_FILE" $OCI_REPO >> $GITHUB_STEP_SUMMARY
74+
echo '```' >> $GITHUB_STEP_SUMMARY

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.helm-charts

toggle/react-serve/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
values-local.yaml

toggle/react-serve/.helmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
values-local.yaml

toggle/react-serve/Chart.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: react-serve
3+
description: "Basic Helm Chart to deploy React Web App"
4+
type: application
5+
version: 0.0.1
6+
sources:
7+
- https://github.com/toggle-corp/charts
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "react-serve.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
6+
{{- end -}}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
13+
*/}}
14+
{{- define "react-serve.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "react-serve.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Return the proper MinIO® image name
36+
*/}}
37+
{{- define "react-serve.container_image" -}}
38+
{{- $imageName := required ".Values.image.name" .Values.image.name -}}
39+
{{- $imageTag := required ".Values.image.tag" .Values.image.tag -}}
40+
{{- printf "%s:%s" $imageName $imageTag -}}
41+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: {{ template "react-serve.fullname" . }}-configmap
5+
labels:
6+
component: web-app-deployment
7+
environment: {{ .Values.environment }}
8+
release: {{ .Release.Name }}
9+
data:
10+
# Provided configs using env
11+
{{- range $name, $value := .Values.env }}
12+
{{ $name }}: {{ $value | quote }}
13+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "react-serve.fullname" . }}
5+
labels:
6+
environment: {{ .Values.environment }}
7+
release: {{ .Release.Name }}
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: {{ template "react-serve.fullname" . }}
13+
release: {{ .Release.Name }}
14+
run: {{ .Release.Name }}
15+
template:
16+
metadata:
17+
labels:
18+
app: {{ template "react-serve.fullname" . }}
19+
release: {{ .Release.Name }}
20+
run: {{ .Release.Name }}
21+
spec:
22+
{{- with .Values.image.pullSecrets }}
23+
imagePullSecrets:
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
containers:
27+
- name: {{ .Values.container.name }}
28+
image: {{ include "react-serve.container_image" . }}
29+
imagePullPolicy: {{ .Values.image.pullPolicy }}
30+
ports:
31+
- name: http
32+
containerPort: {{ .Values.container.port }}
33+
protocol: TCP
34+
resources:
35+
{{- toYaml .Values.resources | nindent 12 }}
36+
envFrom:
37+
- configMapRef:
38+
name: {{ template "react-serve.fullname" . }}-configmap
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.ingress.enabled }}
2+
3+
apiVersion: networking.k8s.io/v1
4+
kind: Ingress
5+
metadata:
6+
name: {{ template "react-serve.fullname" . }}-ingress
7+
labels:
8+
app: {{ template "react-serve.name" . }}
9+
environment: {{ .Values.environment }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
ingressClassName: {{ required "ingress.ingressClassName" .Values.ingress.ingressClassName | quote }}
13+
rules:
14+
- host: {{ required "ingress.hostname" .Values.ingress.hostname | quote }}
15+
http:
16+
paths:
17+
- path: /
18+
pathType: Prefix
19+
backend:
20+
service:
21+
name: {{ template "react-serve.fullname" . }}-svc
22+
port:
23+
number: 80
24+
25+
{{- if .Values.ingress.tls.enabled }}
26+
tls:
27+
- hosts:
28+
- {{ .Values.ingress.host | quote }}
29+
secretName: {{ required "ingress.tls.secretName" .Values.ingress.tls.secretName }}
30+
{{- end }}
31+
32+
{{- end }}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "react-serve.fullname" . }}-svc
5+
labels:
6+
app: {{ template "react-serve.fullname" . }}
7+
environment: {{ .Values.environment }}
8+
release: {{ .Release.Name }}
9+
spec:
10+
type: ClusterIP
11+
selector:
12+
app: {{ template "react-serve.fullname" . }}
13+
release: {{ .Release.Name }}
14+
run: {{ .Release.Name }}
15+
ports:
16+
- protocol: TCP
17+
port: 80
18+
targetPort: {{ .Values.container.port }}

toggle/react-serve/values-test.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fullnameOverride: test-123
2+
3+
image:
4+
name: github.local/react/web-app
5+
tag: latest
6+
pullPolicy: Always
7+
8+
ingress:
9+
hostname: react.web-app.com
10+
ingressClassName: nginx
11+
12+
env:
13+
APP_TITLE: "My APP"
14+
APP_ENVIRONMENT: ALPHA

toggle/react-serve/values.yaml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
environment: prod
2+
3+
fullnameOverride:
4+
5+
## React image (static servied by nginx)
6+
## @param image.name Container image name
7+
## @param image.tag Container image tag
8+
## @param image.pullPolicy Container pull policy `Always|IfNotPresent|Never`
9+
## @param image.pullSecrets Container image pull secrets
10+
##
11+
image:
12+
name:
13+
tag:
14+
pullPolicy: IfNotPresent
15+
pullSecrets:
16+
17+
## React container
18+
## @param container.name Container name
19+
## @param container.port Container port
20+
##
21+
container:
22+
name: react-serve
23+
port: 80
24+
25+
## @param resources Set container requests and limits for different resources like CPU or memory
26+
## Example:
27+
## resources:
28+
## requests:
29+
## cpu: 2
30+
## memory: 512Mi
31+
## limits:
32+
## cpu: 3
33+
## memory: 1024Mi
34+
##
35+
resources:
36+
requests:
37+
cpu: "0.5"
38+
memory: "100Mi"
39+
limits:
40+
cpu: "1"
41+
memory: "100Mi"
42+
43+
ingress:
44+
## @param ingress.enabled Enable an ingress resource
45+
##
46+
enabled: true
47+
## @param ingress.ingressClassName Defines which ingress controller will implement the resource
48+
##
49+
ingressClassName:
50+
## @param ingress.hostname Ingress hostname for the ingress
51+
## Hostname must be provided if Ingress is enabled.
52+
##
53+
hostname:
54+
## @param ingress.tls Ingress TLS configuration
55+
##
56+
tls:
57+
## @param ingress.tls.enabled Enable an tls for ingress resource
58+
##
59+
enabled: false
60+
## @param ingress.tls.secretName Ingress TLS secrets name
61+
## secretName must be provided if Ingress TLS is enabled.
62+
##
63+
secretName:
64+
65+
## @param env with environment variables to pass to the container
66+
## e.g:
67+
## env:
68+
## APP_TITLE: "My React APP"
69+
## APP_ENVIRONMENT: "ALPHA"
70+
##
71+
env:

0 commit comments

Comments
 (0)