diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b5da14d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:20-alpine3.17 AS builder + +WORKDIR /app + +COPY . . + +RUN npm install \ +&& npm run build + +FROM nginx:1.25.1-alpine AS runner + +WORKDIR /usr/share/nginx/html + +ENV NODE_ENV production + +COPY --from=builder /app/build/ . + +COPY default.conf /etc/nginx/conf.d/ + +EXPOSE 80 + +ENV PORT 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/charts/colony-docs/.helmignore b/charts/colony-docs/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/charts/colony-docs/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/colony-docs/Chart.yaml b/charts/colony-docs/Chart.yaml new file mode 100644 index 0000000..22a7abb --- /dev/null +++ b/charts/colony-docs/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +appVersion: f168aa0 +description: colony documentation Helm chart +name: colony-docs +type: application +version: 1.156.0 diff --git a/charts/colony-docs/templates/NOTES.txt b/charts/colony-docs/templates/NOTES.txt new file mode 100644 index 0000000..aa19acd --- /dev/null +++ b/charts/colony-docs/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "colony-docs.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "colony-docs.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "colony-docs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "colony-docs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/colony-docs/templates/_helpers.tpl b/charts/colony-docs/templates/_helpers.tpl new file mode 100644 index 0000000..4ef5493 --- /dev/null +++ b/charts/colony-docs/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "colony-docs.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "colony-docs.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "colony-docs.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "colony-docs.labels" -}} +helm.sh/chart: {{ include "colony-docs.chart" . }} +{{ include "colony-docs.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "colony-docs.selectorLabels" -}} +app.kubernetes.io/name: {{ include "colony-docs.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "colony-docs.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "colony-docs.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/colony-docs/templates/cm.yaml b/charts/colony-docs/templates/cm.yaml new file mode 100644 index 0000000..fca2620 --- /dev/null +++ b/charts/colony-docs/templates/cm.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "colony-docs.fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +data: + CONFIG_ONE: your-first-config + CONFIG_TWO: your-second-config diff --git a/charts/colony-docs/templates/deployment.yaml b/charts/colony-docs/templates/deployment.yaml new file mode 100644 index 0000000..dd89e48 --- /dev/null +++ b/charts/colony-docs/templates/deployment.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "colony-docs.fullname" . }} + labels: + {{- include "colony-docs.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "colony-docs.selectorLabels" . | nindent 6 }} + revisionHistoryLimit: 1 + template: + metadata: + labels: + {{- include "colony-docs.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "colony-docs.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ (default .Chart.AppVersion .Values.image.tag) }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 1 + timeoutSeconds: 30 + readinessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + timeoutSeconds: 30 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/colony-docs/templates/ingress.yaml b/charts/colony-docs/templates/ingress.yaml new file mode 100644 index 0000000..b01b106 --- /dev/null +++ b/charts/colony-docs/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "colony-docs.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "colony-docs.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/colony-docs/templates/service.yaml b/charts/colony-docs/templates/service.yaml new file mode 100644 index 0000000..bc4f016 --- /dev/null +++ b/charts/colony-docs/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "colony-docs.fullname" . }} + labels: + {{- include "colony-docs.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "colony-docs.selectorLabels" . | nindent 4 }} diff --git a/charts/colony-docs/templates/serviceaccount.yaml b/charts/colony-docs/templates/serviceaccount.yaml new file mode 100644 index 0000000..1d37e35 --- /dev/null +++ b/charts/colony-docs/templates/serviceaccount.yaml @@ -0,0 +1,9 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "colony-docs.serviceAccountName" . }} + labels: +{{ include "colony-docs.labels" . | nindent 4 }} +automountServiceAccountToken: true +{{- end -}} diff --git a/charts/colony-docs/templates/tests/test-connection.yaml b/charts/colony-docs/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e384a04 --- /dev/null +++ b/charts/colony-docs/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "colony-docs.fullname" . }}-test-connection" + labels: +{{ include "colony-docs.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "colony-docs.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/colony-docs/values.yaml b/charts/colony-docs/values.yaml new file mode 100644 index 0000000..c297524 --- /dev/null +++ b/charts/colony-docs/values.yaml @@ -0,0 +1,69 @@ +# Default values for colony-docs. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/konstructio/colony-docs + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: colony-docs-sa + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # Change to "letsencrypt-staging" while testing adjustments, change to "letsencrypt-prod" after confirming LE certificate was issued + # cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: example.com + paths: + - / + tls: + - secretName: colony-docs-tls + hosts: + - colony-docs.example.com + + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +resources: + limits: + cpu: 100m + memory: "128Mi" + requests: + cpu: 40m + memory: "64Mi" + +nodeSelector: {} + +tolerations: [] + +affinity: {} +