Skip to content

Commit

Permalink
Merge pull request #9 from scientist-softserv/i3-deploy-r2-staging
Browse files Browse the repository at this point in the history
i3-deploy-r2-staging
  • Loading branch information
aprilrieger authored Aug 20, 2024
2 parents 3eebdc9 + e72cc47 commit d1ca704
Show file tree
Hide file tree
Showing 27 changed files with 780 additions and 29 deletions.
14 changes: 7 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
APP_HOME=/home/app/webapp
DATABASE_ADAPTER=mysql2
DATABASE_HOST=mysql
DATABASE_NAME=indiana_arclight
DATABASE_USER=indiana_arclight
DATABASE_NAME=archives-online
DATABASE_USER=archives-online
DATABASE_PASSWORD=DatabaseFTW
DATABASE_ROOT_PASSWORD=root
MAIL_MAILER=log
Expand All @@ -18,10 +18,10 @@ MYSQL_USER=${DATABASE_USER}
MYSQL_PASSWORD=${DATABASE_PASSWORD}
PASSENGER_APP_ENV=development
SECRET_KEY_BASE=656c0be3f48358e7c129bd183cf58083f801eaa3b36c213a24e3299a9c64c507aa69d0fa473511492065afb8d4016d98f828b51cd7e437c7f46a9964593a9087
SOLR_COLLECTION_NAME=indiana-arclight-development
SOLR_CONFIGSET_NAME=indiana-arclight
SOLR_CORE=blacklight-core
SOLR_COLLECTION_NAME=archives-online
SOLR_CONFIGSET_NAME=archives-online
SOLR_CORE=${SOLR_CONFIGSET_NAME}
SOLR_HOST=solr
SOLR_PORT=8983
SOLR_URL=http://solr:8983/solr/blacklight-core
TEST_DB=indiana_arclight
SOLR_URL=http://solr:8983/solr/${SOLR_CORE}
TEST_DB=archives_online_test
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN echo 'Downloading Packages' && \
libsasl2-dev \
nodejs \
pv \
rsync \
tzdata \
mysql-client && \
apt-get clean && \
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ docker compose up

It will take some time for the application to start up, and a bit longer if it's the first startup. When you see `Passenger core running in multi-application mode.` or `Listening on tcp://0.0.0.0:3000` in the logs, the application is ready.
If you used Dory, the application will be available from the browser at `http://indiana-arclight.test`.
If you used Dory, the application will be available from the browser at `http://archives-online.test`.
**You are now ready to start using archives_online!**
Expand Down Expand Up @@ -110,12 +110,12 @@ archives_online relies on helm charts for deployment to kubernetes containers. W
There are 2 files pre-loaded and in order to run them you need to be inside the web container:
```
docker compose exec web bash
bundle exec traject -u http://solr:8983/solr/blacklight-core -i xml -c lib/arclight/traject/ead2_config.rb data/VAD8042.xml
bundle exec traject -u http://solr:8983/solr/blacklight-core -i xml -c lib/arclight/traject/ead2_config.rb data/InU-Li-VAD1572.xml
bundle exec traject -u http://solr:8983/solr/${SOLR_CORE} -i xml -c lib/arclight/traject/ead2_config.rb data/VAD8042.xml
bundle exec traject -u http://solr:8983/solr/${SOLR_CORE} -i xml -c lib/arclight/traject/ead2_config.rb data/InU-Li-VAD1572.xml
```
#### Without Docker
```
bundle exec traject -u http://solr:8983/solr/blacklight-core -i xml -c lib/arclight/traject/ead2_config.rb data/VAD8042.xml
bundle exec traject -u http://solr:8983/solr/blacklight-core -i xml -c lib/arclight/traject/ead2_config.rb data/InU-Li-VAD1572.xml
bundle exec traject -u http://solr:8983/solr/${SOLR_CORE} -i xml -c lib/arclight/traject/ead2_config.rb data/VAD8042.xml
bundle exec traject -u http://solr:8983/solr/${SOLR_CORE} -i xml -c lib/arclight/traject/ead2_config.rb data/InU-Li-VAD1572.xml
```
28 changes: 28 additions & 0 deletions bin/checkout_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Save the current branch name
current_branch=$(git rev-parse HEAD)

# Fetch any updates from the origin
if $(git rev-parse --is-shallow-repository); then
git fetch --unshallow -a origin
else
git fetch -a origin
fi

# Loop through all remote branches
for branch in $(git branch -r | grep -v '\->'); do
# Checkout each branch
if [[ $branch == *origin* ]]; then
branch_name="${branch#origin/}"
echo "Checking out $branch_name branch..."
git checkout $branch_name
else
echo "$branch is not from the origin"
fi
done

# Switch back to the original branch
git checkout $current_branch

echo "Operation complete, returned to $current_branch"
37 changes: 37 additions & 0 deletions bin/helm_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

# This script wraps up helm deployment. It is meant as a clear starting point for
# commandline deployment or CI based deployment. It requires the following ENV vars be set
#
# CHART_VERSION: this is the version of the hyrax chart you want to deploy. default - 0.22.0
# DEPLOY_IMAGE: this is the build image that runs the rails application. Typically this would run puma or passenger. eg: samvera/hyrax or ghcr.io/samvera/hyku. Defaults to gcrh.io/samvera/hyku
# WORKER_IMAGE: this is the worker target, usually built from the same Dockerfile as DEPLOY_IMAGE. eg: samvera/hyrax/worker or ghcr.io/samvera/hyku/worker. Defaults to gcrh.io/samvera/hyku/worker
# DEPLOY_TAG: name of of the tag you want to deploy for deploy image. eg: "latest" or "v3.0.1" or "f123asdf1". Defaults to latest
# WORKER_TAG: name of of the tag you want to deploy for deploy image. eg: "latest" or "v3.0.1" or "f123asdf1". Defaults to DEPLOY_TAG
# HELM_EXTRA_ARGS: any additional arguments you'd like passed to helm upgrade directly. can be blank.

if [ -z "$1" ] || [ -z "$2" ]
then
echo './bin/helm_deploy RELEASE_NAME NAMESPACE'
exit 1
fi
release_name="${1//_/-}"
namespace="${2//_/-}"

DEPLOY_IMAGE="${DEPLOY_IMAGE:-ghcr.io/scientist-softserv/archives_online}"
DEPLOY_TAG="${DEPLOY_TAG:-latest}"
echo $DEPLOY_TAG

helm repo update

helm upgrade \
--install \
--atomic \
--timeout 15m0s \
--set image.repository="$DEPLOY_IMAGE" \
--set image.tag="$DEPLOY_TAG" \
$HELM_EXTRA_ARGS \
--namespace="$namespace" \
--create-namespace \
"$release_name" \
chart
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: mysql
repository: https://charts.bitnami.com/bitnami
version: 11.1.15
digest: sha256:6933e24d32aa7cb20d32992c0a08db2f6194011b333f247f8cfc385c875d1193
generated: "2024-08-19T11:00:00.946636-07:00"
11 changes: 11 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: chart
description: Archives Online, an application supporting discovery of archival materials, based on ArcLight
type: application
version: 0.1.0
appVersion: "1.0.0"

dependencies:
- name: mysql
version: 11.1.15
repository: https://charts.bitnami.com/bitnami
Binary file added chart/charts/mysql-11.1.15.tgz
Binary file not shown.
22 changes: 22 additions & 0 deletions chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 }}{{ .path }}
{{- 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 "chart.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 "chart.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chart.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 "chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.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 "chart.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 "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions chart/templates/configmap-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "chart.fullname" . }}-env
labels:
app.kubernetes.io/name: {{ include "chart.name" . }}
helm.sh/chart: {{ include "chart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
{{- range $key, $value := .Values.env.configmap }}
{{ $key }}: "{{ $value }}"
{{- end }}
90 changes: 90 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
checksum/configmap-env: {{ include (print $.Template.BasePath "/configmap-env.yaml") . | sha256sum }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "chart.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "chart.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
- name: shared
persistentVolumeClaim:
claimName: {{ template "chart.fullname" . }}-shared
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
readinessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 30
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 60
periodSeconds: 120
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
- mountPath: /home/app/webapp/public/assets-new
name: shared
subPath: assets
- mountPath: /home/app/webapp/public/packs
name: shared
subPath: packs
- mountPath: /home/app/webapp/public/system
name: shared
subPath: system
{{- end }}
envFrom:
- configMapRef:
name: {{ template "chart.fullname" . }}-env
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
32 changes: 32 additions & 0 deletions chart/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "chart.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
Loading

0 comments on commit d1ca704

Please sign in to comment.