Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/gql' into gql
Browse files Browse the repository at this point in the history
  • Loading branch information
mathhulk committed Nov 7, 2024
2 parents 722d3b0 + 3db2d35 commit 5987bde
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ jobs:
username: root
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Uninstall the old helm chart if it exists
helm uninstall bt-dev-app-${{ needs.compute-sha.outputs.sha_short }} || true
# Install new chart
helm install bt-dev-app-${{ needs.compute-sha.outputs.sha_short }} ./app --namespace=bt \
--set env=dev \
--set ttl=${{ inputs.ttl }} \
Expand All @@ -62,3 +67,7 @@ jobs:
--set mongoUri=mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \
--set nodeEnv=development
# Check container status
kubectl rollout status --timeout=180s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-backend
kubectl rollout status --timeout=180s deployment bt-dev-app-${{ needs.compute-sha.outputs.sha_short }}-frontend
9 changes: 9 additions & 0 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ jobs:
username: root
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Check if the Helm release exists
if helm status bt-prod-app ; then
# Restart deployments if the Helm release exists
kubectl rollout restart deployment bt-prod-app-backend
kubectl rollout restart deployment bt-prod-app-frontend
else
# Install the Helm release if it doesn't exist
helm install bt-prod-app ./app --namespace=bt \
--set host=stanfurdtime.com
fi
# Check container status
kubectl rollout status --timeout=180s deployment bt-prod-app-backend
kubectl rollout status --timeout=180s deployment bt-prod-app-frontend
9 changes: 9 additions & 0 deletions .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ jobs:
username: root
key: ${{ secrets.SSH_KEY }}
script: |
set -e # Exit immediately if a command fails
cd ./infra
# Check if the Helm release exists
if helm status bt-stage-app ; then
# Restart deployments if the Helm release exists
kubectl rollout restart deployment bt-stage-app-backend
kubectl rollout restart deployment bt-stage-app-frontend
else
# Install the Helm release if it doesn't exist
helm install bt-stage-app ./app --namespace=bt \
--set env=stage \
--set frontend.image.tag=latest \
Expand All @@ -41,3 +46,7 @@ jobs:
--set mongoUri=mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-stage-redis-master.bt.svc.cluster.local:6379
fi
# Check container status
kubectl rollout status --timeout=180s deployment bt-stage-app-backend
kubectl rollout status --timeout=180s deployment bt-stage-app-frontend
3 changes: 3 additions & 0 deletions apps/backend/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import loaders from "./loaders";
export default async (config: Config) => {
const app = express();
app.set("trust proxy", 1);
app.get("/healthz", (_, res) => {
res.status(200).send("OK");
});

await loaders(app);

Expand Down
10 changes: 10 additions & 0 deletions infra/app/templates/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ spec:
value: "_"
- name: SIS_COURSE_APP_KEY
value: "_"
- name: SIS_TERM_APP_ID
value: "_"
- name: SIS_TERM_APP_KEY
value: "_"
- name: GOOGLE_CLIENT_ID
value: "_"
- name: GOOGLE_CLIENT_SECRET
value: "_"
- name: SESSION_SECRET
value: "_"
readinessProbe:
httpGet:
path: /healthz
port: {{ .Values.backend.port }}
initialDelaySeconds: 15
periodSeconds: 3

---

Expand Down
8 changes: 7 additions & 1 deletion infra/app/templates/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ spec:
containers:
- name: cleanup
image: alpine/helm
command: ['sh', '-c', 'sleep $(( {{ .Values.ttl }} * 60 * 60 )); helm uninstall {{ .Release.Name }}']
command:
- sh
- -c
- |
echo "Cleaning up {{ .Release.Name }} in {{ .Values.ttl }} hours"
sleep {{ .Values.ttl }}h
helm uninstall {{ .Release.Name }}
restartPolicy: Never
{{ end }}
6 changes: 6 additions & 0 deletions infra/app/templates/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: {{ .Values.frontend.port }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.frontend.port }}
initialDelaySeconds: 15
periodSeconds: 3

---

Expand Down
4 changes: 4 additions & 0 deletions infra/app/templates/updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ spec:
value: "_"
- name: SIS_COURSE_APP_KEY
value: "_"
- name: SIS_TERM_APP_ID
value: "_"
- name: SIS_TERM_APP_KEY
value: "_"
- name: GOOGLE_CLIENT_ID
value: "_"
- name: GOOGLE_CLIENT_SECRET
Expand Down

0 comments on commit 5987bde

Please sign in to comment.