Skip to content

Commit

Permalink
Frontend font support and font deployment (#2493)
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Grady <[email protected]>
  • Loading branch information
imnasnainaec and jmgrady authored Sep 6, 2023
1 parent 6d85b1f commit 98784f8
Show file tree
Hide file tree
Showing 62 changed files with 1,697 additions and 375 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ __pycache__
*.pyc
venv

# Font files
*.ttf
*.woff
*.woff2
public/fonts

# Intermediate files for dictionary import scripts
src/resources/dictionaries/*.aff
src/resources/dictionaries/*.dic
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@
"axios",
"bootable",
"Bson",
"Charis",
"containerd",
"devs",
"Doulos",
"Dups",
"endcap",
"globaltool",
"Guids",
"kubeconfig",
"langtags",
"ldml",
"letsencrypt",
"Linq",
Expand All @@ -58,6 +61,7 @@
"mongosh",
"nerdctl",
"notistack",
"Noto",
"nspell",
"oneshot",
"openapi",
Expand All @@ -69,7 +73,8 @@
"sched",
"sillsdev",
"Sldr",
"Subtag",
"subtag",
"subtags",
"targetdir",
"textfile",
"thecombine",
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ FROM nginx:1.25

WORKDIR /app

ENV USER_GUIDE_HOST_DIR /usr/share/nginx/user_guide
ENV FRONTEND_HOST_DIR /usr/share/nginx/html
ENV HOST_DIR /usr/share/nginx
ENV USER_GUIDE_HOST_DIR ${HOST_DIR}/user_guide
ENV FRONTEND_HOST_DIR ${HOST_DIR}/html

RUN mkdir /etc/nginx/templates
RUN mkdir /etc/nginx/page_templates
RUN mkdir ${HOST_DIR}/fonts
RUN mkdir ${FRONTEND_HOST_DIR}/scripts
RUN mkdir ${FRONTEND_HOST_DIR}/url_moved

Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/aws-login/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ awsEcr:
cronJobName: ecr-cred-helper-cron
dockerEmail: [email protected]
image: sillsdev/aws-kubectl
imageTag: "0.2.1"
imageTag: "0.3.0"
jobName: ecr-cred-helper
schedule: "0 */8 * * *"
secretsName: aws-ecr-credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,20 @@ spec:
configMapKeyRef:
key: CONFIG_USE_CONNECTION_URL
name: env-frontend
- name: SERVER_NAME
- name: CONFIG_OFFLINE
valueFrom:
configMapKeyRef:
key: SERVER_NAME
key: CONFIG_OFFLINE
name: env-frontend
- name: ENV_HTTP_ONLY
- name: CONFIG_EMAIL_ENABLED
valueFrom:
configMapKeyRef:
key: ENV_HTTP_ONLY
key: CONFIG_EMAIL_ENABLED
name: env-frontend
- name: SERVER_NAME
valueFrom:
configMapKeyRef:
key: SERVER_NAME
name: env-frontend
{{- if .Values.configAnalyticsWriteKey }}
- name: CONFIG_ANALYTICS_WRITE_KEY
Expand All @@ -70,9 +75,18 @@ spec:
- containerPort: 80
- containerPort: 443
resources: {}
volumeMounts:
- mountPath: /usr/share/nginx/fonts
name: font-data
readOnly: true
restartPolicy: Always
{{- if ne .Values.global.pullSecretName "None" }}
imagePullSecrets:
- name: {{ .Values.global.pullSecretName }}
{{- end }}
volumes:
- name: font-data
persistentVolumeClaim:
claimName: font-data

status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ data:
CONFIG_USE_CONNECTION_URL: "true"
CONFIG_CAPTCHA_REQD: {{ .Values.configCaptchaRequired | quote }}
CONFIG_CAPTCHA_SITE_KEY: {{ .Values.configCaptchaSiteKey | quote }}
CONFIG_EMAIL_ENABLED: {{ .Values.configEmailEnabled | quote }}
CONFIG_OFFLINE: {{ .Values.configOffline | quote }}
CONFIG_EMAIL_ENABLED: {{ and .Values.configEmailEnabled (empty .Values.global.combineSmtpUsername | not) | quote }}
CONFIG_SHOW_CERT_EXPIRATION: {{ .Values.configShowCertExpiration | quote }}
{{- if .Values.configAnalyticsWriteKey }}
CONFIG_ANALYTICS_WRITE_KEY: {{ .Values.configAnalyticsWriteKey | quote }}
{{- end }}
ENV_HTTP_ONLY: "yes"
4 changes: 3 additions & 1 deletion deploy/helm/thecombine/charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Declare variables to be passed into your templates.

global:
combineSmtpUsername: "Override"
serverName: localhost
pullSecretName: aws-login-credentials
# Update strategy should be "Recreate" or "Rolling Update"
Expand All @@ -17,6 +18,7 @@ imageName: combine_frontend
combineAddlDomainList: ""
configCaptchaRequired: "false"
configCaptchaSiteKey: "None - from frontend chart"
configEmailEnabled: "false"
configOffline: "false"
configEmailEnabled: "true"
configShowCertExpiration: "false"
configAnalyticsWriteKey: ""
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- image: sillsdev/aws-kubectl:0.2.1
- image: sillsdev/aws-kubectl:0.3.0
imagePullPolicy: Always
name: daily-backup
command:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if empty .Values.updateFontsSchedule | not }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: update-fonts
namespace: {{ .Release.Namespace | quote }}
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
creationTimestamp: null
spec:
ttlSecondsAfterFinished: 86400
template:
metadata:
creationTimestamp: null
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- image: sillsdev/aws-kubectl:0.3.0
imagePullPolicy: Always
name: update-fonts
command:
- kubectl
args:
- -n
- thecombine
- exec
- deployment/maintenance
- --
- get-fonts.sh
resources: {}
securityContext:
capabilities: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
{{- if ne .Values.global.pullSecretName "None" }}
imagePullSecrets:
- name: {{ .Values.global.pullSecretName }}
{{- end }}
dnsPolicy: ClusterFirst
restartPolicy: Never
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
schedule: {{ .Values.updateFontsSchedule }}
successfulJobsHistoryLimit: 1
suspend: false
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ spec:
args: [ 'sleep infinity & PID=$! ; trap "kill $PID" INT TERM ; wait' ]
image: {{ template "maintenance.containerImage" . }}
imagePullPolicy: {{ template "maintenance.imagePullPolicy" . }}
securityContext:
runAsUser: 999
runAsGroup: 999
env:
# values for AWS Access
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
Expand All @@ -57,6 +61,7 @@ spec:
configMapKeyRef:
key: aws_bucket
name: env-maintenance
# values used for backup/restore
- name: db_files_subdir
valueFrom:
configMapKeyRef:
Expand Down Expand Up @@ -87,10 +92,29 @@ spec:
configMapKeyRef:
key: backup_filter
name: env-maintenance
# values used for font caching
- name: font_dir
valueFrom:
configMapKeyRef:
key: font_dir
name: env-maintenance
- name: local_font_url
valueFrom:
configMapKeyRef:
key: local_font_url
name: env-maintenance
resources: {}
volumeMounts:
- mountPath: {{ .Values.fontsDir }}
name: font-data
readOnly: false
restartPolicy: Always
{{- if ne .Values.global.pullSecretName "None" }}
imagePullSecrets:
- name: {{ .Values.global.pullSecretName }}
{{- end }}
volumes:
- name: font-data
persistentVolumeClaim:
claimName: font-data
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ data:
backup_filter: {{ template "maintenance.backupNameFilter" . }}
wait_time: {{ .Values.waitTime | quote }}
max_backups: {{ .Values.maxBackups | quote }}
font_dir: {{ .Values.fontsDir | quote }}
local_font_url: {{ .Values.localFontUrl | quote }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "install-fonts"
namespace: {{ .Release.Namespace | quote }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install, post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
metadata:
creationTimestamp: null
name: "{{ .Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- image: sillsdev/aws-kubectl:0.3.0
imagePullPolicy: Always
name: "install-fonts"
command:
- kubectl
args:
- -n
- thecombine
- exec
- deployment/maintenance
- --
- /usr/bin/python3
- /home/user/.local/bin/get_fonts.py
{{- if .Values.localLangList }}
- --langs
{{- range $lang := .Values.localLangList }}
- {{ $lang | quote }}
{{- end }}
{{- end }}
resources: {}
securityContext:
capabilities: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: Default
restartPolicy: Never
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
9 changes: 9 additions & 0 deletions deploy/helm/thecombine/charts/maintenance/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ waitTime: "120"
awsS3BackupLoc: backups
dbFilesSubdir: dump
backendFilesSubdir: ".CombineFiles"

#######################################
# Variables controlling font updates
#######################################

updateFontsSchedule: ""
fontsDir: "/home/user/fonts"
localFontUrl: "/fonts"
localLangList: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
name: font-data
namespace: {{ .Release.Namespace }}
spec:
accessModes:
- {{ .Values.global.fontStorageAccessMode }}
resources:
requests:
storage: {{ .Values.global.fontStorageSize | quote }}
status: {}
4 changes: 4 additions & 0 deletions deploy/helm/thecombine/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ global:
combineJwtSecretKey: "Override"
combineSmtpUsername: "Override"
combineSmtpPassword: "Override"
fontStorageAccessMode: "ReadWriteOnce"
fontStorageSize: 1Gi
offline: false
imageTag: "latest"
# Define the image registry to use (may be blank for local images)
imageRegistry: awsEcr
Expand Down Expand Up @@ -52,5 +55,6 @@ maintenance:
backupSchedule: ""
# Maximum number of backups to keep on AWS S3 service
maxBackups: "3"
updateFontsSchedule: ""

ingressClass: nginx
Loading

0 comments on commit 98784f8

Please sign in to comment.