Last active
March 24, 2023 19:01
-
-
Save youcefguichi/1e1109a99972bcb4f059627aa423c51d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {{- $websiteDirectory := regexFind "([^\\/]+$)" .Values.staticSite.gitCloneUrl | replace ".git" "" }} | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: {{ .Release.Name }} | |
| namespace: {{ .Release.Namespace }} | |
| labels: | |
| {{- include "static-site.labels" . | nindent 4 }} | |
| spec: | |
| {{- if not .Values.autoscaling.enabled }} | |
| replicas: {{ .Values.replicaCount }} | |
| {{- end }} | |
| selector: | |
| matchLabels: | |
| {{- include "static-site.selectorLabels" . | nindent 6 }} | |
| template: | |
| metadata: | |
| {{- with .Values.podAnnotations }} | |
| annotations: | |
| {{- toYaml . | nindent 8 }} | |
| {{- end }} | |
| labels: | |
| {{- include "static-site.selectorLabels" . | nindent 8 }} | |
| spec: | |
| {{- with .Values.imagePullSecrets }} | |
| imagePullSecrets: | |
| {{- toYaml . | nindent 8 }} | |
| {{- end }} | |
| serviceAccountName: {{ include "static-site.serviceAccountName" . }} | |
| securityContext: | |
| {{- toYaml .Values.podSecurityContext | nindent 8 }} | |
| volumes: | |
| - name: static-files | |
| emptyDir: {} | |
| initContainers: | |
| - name: init-con | |
| image: {{ .Values.staticSite.buildImage }}:{{ .Values.staticSite.buildTag}} | |
| {{- if .Values.staticSite.buildCommand}} | |
| command: | |
| - sh | |
| - -c | |
| - | | |
| git clone {{ .Values.staticSite.gitCloneUrl}} && | |
| cd {{ $websiteDirectory }} && | |
| {{ .Values.staticSite.buildCommand}} && | |
| mkdir -p /usr/share/nginx/html && | |
| cp -r ./public/. /usr/share/nginx/html | |
| {{- end }} | |
| volumeMounts: | |
| - name: static-files | |
| mountPath: /usr/share/nginx/html | |
| containers: | |
| - name: {{ .Chart.Name }} | |
| securityContext: | |
| {{- toYaml .Values.securityContext | nindent 12 }} | |
| image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | |
| imagePullPolicy: {{ .Values.image.pullPolicy }} | |
| volumeMounts: | |
| - name: static-files | |
| mountPath: /usr/share/nginx/html | |
| ports: | |
| - name: http | |
| containerPort: {{ .Values.service.port }} | |
| protocol: TCP | |
| --- | |
| # custo-values.yaml | |
| staticSite: | |
| gitCloneUrl: https://github.com/YoucefGuichi/gatspy-site.git | |
| buildImage: node | |
| buildTag: latest | |
| buildCommand: | |
| "npm install && | |
| npm install -g gatsby-cli && | |
| gatsby build" | |
| builtAssets: public/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
static-siteandstaticSiteare used in var names. I guess only one of them,staticSiteshould bename: {{ .Chart.Name }},name: {{ .Release.Name }}can you copy the same naming approach that we use in onechart? I don't think.Chart.Nameis used.builtAssetsis not used in the implementation. I think that needs to be configurable as build scripts output dir vary