Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deployment to staging #38

Merged
merged 50 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8d0d6ef
Add build to deploy deps
sneakycrow Dec 23, 2024
c057e09
Remove unused permissions keys
sneakycrow Dec 23, 2024
c13cfd3
Fix secret name
sneakycrow Dec 23, 2024
7e052d7
Fix image name step
sneakycrow Dec 23, 2024
c50c064
Fix build-web to use correct yarn.lock files
sneakycrow Dec 23, 2024
2ae8783
Temporarily disable deployment step, add validation step
sneakycrow Dec 23, 2024
b0d2880
Remove full image name, just output the tag hash
sneakycrow Dec 23, 2024
165ee16
Recompose full image name using just tag from output
sneakycrow Dec 23, 2024
c2a4da6
Fix deployment configmap ref
sneakycrow Dec 23, 2024
2a51ba6
Fix the incorrect image being used
sneakycrow Dec 23, 2024
82b0f49
Reduce rollout timeout to 2 minutes
sneakycrow Dec 23, 2024
b56bb5b
Add database url to deployment
sneakycrow Dec 23, 2024
bd8ec01
Add ingress configuration
sneakycrow Dec 23, 2024
2bb645f
Add initial queue k8s configs
sneakycrow Dec 24, 2024
67dc83c
Fix deployment
sneakycrow Dec 24, 2024
18b7894
Add QUEUE_IMAGE to cicd
sneakycrow Dec 24, 2024
8782c38
Update name
sneakycrow Dec 24, 2024
8cec7ac
Add initial ui k8s configuration
sneakycrow Dec 24, 2024
cf1003b
Add a health check endpoint to the ui
sneakycrow Dec 24, 2024
244a182
Add other secret refs
sneakycrow Dec 24, 2024
5244094
Fix capitalization
sneakycrow Dec 24, 2024
3999b7c
Update the database url secret
sneakycrow Dec 24, 2024
dd681cc
Fix ui deloyment errors
sneakycrow Dec 24, 2024
9f04d91
Fix queue and ui image
sneakycrow Dec 24, 2024
9db66df
fix the secret ref
sneakycrow Dec 24, 2024
a2de9dc
Remove database secret from ui
sneakycrow Dec 24, 2024
fb09442
Remove the envFrom for farmhand-db
sneakycrow Dec 24, 2024
0ce3476
Fix twitch redirect uri
sneakycrow Dec 24, 2024
5948448
Update rust log for api
sneakycrow Dec 24, 2024
7f7e235
Fix twitch secret ref
sneakycrow Dec 24, 2024
0745302
Fix the UI api url
sneakycrow Dec 24, 2024
cc60c3e
Fix twitch redirect uri to point at api
sneakycrow Dec 24, 2024
6f99557
Increase the interval to 250
sneakycrow Dec 24, 2024
dd916a2
Add headers debug statement
sneakycrow Dec 24, 2024
c72a55c
Add cors setting to nginx ingress
sneakycrow Dec 24, 2024
24d50b1
Update nginx ingress again
sneakycrow Dec 24, 2024
472d965
Include credentials, expose Authorization
sneakycrow Dec 24, 2024
79a51d2
try adding configuration snippet
sneakycrow Dec 24, 2024
8701a0d
Remove validation step
sneakycrow Dec 24, 2024
43b67d6
Update the proxy pass headers
sneakycrow Dec 24, 2024
cab7db2
Try auth snippet annotation
sneakycrow Dec 24, 2024
70a3797
Try another annotation....
sneakycrow Dec 24, 2024
ac4aaf6
Try using configmap and mode: cors
sneakycrow Dec 24, 2024
e95a617
Try this gnarly version
sneakycrow Dec 24, 2024
bb8739c
Add more debugging for auth issue
sneakycrow Dec 24, 2024
6794478
Update debugging again
sneakycrow Dec 24, 2024
fbb1879
Update configma to https
sneakycrow Dec 24, 2024
45972e7
Update https configuration
sneakycrow Dec 24, 2024
99d488f
Change back to http
sneakycrow Dec 24, 2024
e6c911b
Disable upload route
sneakycrow Dec 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ on:
workflow_dispatch:
workflow_call:
outputs:
api_image:
description: "The full API image tag"
value: ${{ jobs.build-api.outputs.image_tag }}
queue_image:
description: "The full Queue image tag"
value: ${{ jobs.build-queue.outputs.image_tag }}
ui_image:
description: "The full UI image tag"
value: ${{ jobs.build-ui.outputs.image_tag }}
image_tag:
description: "The tag for all images in this run"
value: ${{ jobs.setup.outputs.version }}

jobs:
setup:
Expand All @@ -34,11 +28,6 @@ jobs:
build-api:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -76,11 +65,6 @@ jobs:
build-queue:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -118,11 +102,6 @@ jobs:
build-ui:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build web
name: build ui

on:
push:
Expand All @@ -9,11 +9,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: packages/web

steps:
- uses: actions/checkout@v4

Expand All @@ -24,14 +19,14 @@ jobs:
cache: "yarn"
cache-dependency-path: |
yarn.lock
packages/web/yarn.lock
services/barn-ui/yarn.lock

# Cache the build output directory
- name: Cache build output
uses: actions/cache@v4
with:
path: |
packages/web/.svelte-kit
services/barn-ui/.svelte-kit
key: ${{ runner.os }}-web-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-web-build-
Expand All @@ -42,7 +37,7 @@ jobs:
with:
path: |
node_modules
packages/web/node_modules
services/barn-ui/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to Staging
name: deploy - staging

on:
workflow_dispatch:
Expand All @@ -14,25 +14,27 @@ jobs:
deploy:
runs-on: ubuntu-latest
environment: staging

needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
token: ${{ secrets.DO_REGISTRY_KEY }}

- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ vars.CLUSTER_NAME }}

- name: Update kustomization
run: |
cd k8s/overlays/staging
kustomize edit set image api=${{ needs.build.outputs.api_image }}
kustomize edit set image api=${{ secrets.DO_REGISTRY }}/${{ vars.API_IMAGE }}:${{ needs.build.outputs.image_tag }}
kustomize edit set image queue=${{ secrets.DO_REGISTRY }}/${{ vars.QUEUE_IMAGE }}:${{ needs.build.outputs.image_tag }}
kustomize edit set image ui=${{ secrets.DO_REGISTRY }}/${{ vars.UI_IMAGE }}:${{ needs.build.outputs.image_tag }}

- name: Deploy to staging
run: |
kubectl apply -k k8s/overlays/staging
kubectl rollout status deployment/api -n staging
kubectl rollout status deployment/farmhand-api-staging -n staging --timeout=2m
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# farmhand

[![build api](https://github.com/sneakycrow/farmhand/actions/workflows/build-api.yml/badge.svg)](https://github.com/sneakycrow/farmhand/actions/workflows/build-api.yml)
[![build web](https://github.com/sneakycrow/farmhand/actions/workflows/build-web.yml/badge.svg)](https://github.com/sneakycrow/farmhand/actions/workflows/build-web.yml)
[![build ui](https://github.com/sneakycrow/farmhand/actions/workflows/build-ui.yml/badge.svg)](https://github.com/sneakycrow/farmhand/actions/workflows/build-ui.yml)
[![build queue](https://github.com/sneakycrow/farmhand/actions/workflows/build-queue.yml/badge.svg)](https://github.com/sneakycrow/farmhand/actions/workflows/build-queue.yml)

Farmhand is a powerful, open-source clip and VOD management system built for creators and artists who want more control over their content.
Expand Down
3 changes: 3 additions & 0 deletions config/queue.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ RUN apt-get update && apt-get install -y \
# Copy the binary from builder
COPY --from=builder /usr/local/bin/forge /usr/local/bin/forge

# Expose the health check server
EXPOSE 8080

# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/forge"]
4 changes: 4 additions & 0 deletions k8s/base/api/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ kind: ConfigMap
metadata:
name: farmhand-api-config
data:
FRONTEND_URL: "https://staging.farmhand.witchscrow.com"
RUST_LOG: "api=debug,db=debug,queue=debug,tower_http=debug,axum::rejection=trace"
FFMPEG_LOCATION: "/opt/homebrew/bin/ffmpeg" # TODO: Make this is the right path for docker context
TWITCH_REDIRECT_URI: "https://staging.api.farmhand.witchscrow.com/auth/twitch/callback"
LOG_LEVEL: "api=debug"
23 changes: 22 additions & 1 deletion k8s/base/api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ spec:
- containerPort: 3000
envFrom:
- configMapRef:
name: api-config
name: farmhand-api-config
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: farmhand-db
key: uri
- name: TWITCH_CLIENT_ID
valueFrom:
secretKeyRef:
name: twitch-credentials
key: client-id
- name: TWITCH_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: twitch-credentials
key: client-secret
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: jwt
key: secret
resources:
requests:
cpu: "100m"
Expand Down
5 changes: 0 additions & 5 deletions k8s/base/api/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ resources:
- deployment.yaml
- service.yaml
- configmap.yaml

images:
- name: api
newName: placeholder
newTag: placeholder
6 changes: 6 additions & 0 deletions k8s/base/queue/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: farmhand-queue-config
data:
LOG_LEVEL: "queue=debug"
40 changes: 40 additions & 0 deletions k8s/base/queue/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: farmhand-queue
spec:
selector:
matchLabels:
app: farmhand-queue
template:
metadata:
labels:
app: farmhand-queue
spec:
containers:
- name: farmhand-queue
image: queue
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: farmhand-queue-config
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: farmhand-db
key: uri
resources:
requests:
cpu: "100m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
6 changes: 6 additions & 0 deletions k8s/base/queue/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
- configmap.yaml
6 changes: 6 additions & 0 deletions k8s/base/ui/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: farmhand-ui-config
data:
API_URL: "https://staging.api.farmhand.witchscrow.com"
34 changes: 34 additions & 0 deletions k8s/base/ui/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: farmhand-ui
spec:
selector:
matchLabels:
app: farmhand-ui
template:
metadata:
labels:
app: farmhand-ui
spec:
containers:
- name: farmhand-ui
image: ui
ports:
- containerPort: 3000
envFrom:
- configMapRef:
name: farmhand-ui-config
resources:
requests:
cpu: "100m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
7 changes: 7 additions & 0 deletions k8s/base/ui/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
- service.yaml
- configmap.yaml
11 changes: 11 additions & 0 deletions k8s/base/ui/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: farmhand-ui
spec:
selector:
app: farmhand-ui
ports:
- port: 80
targetPort: 3000
type: ClusterIP
Loading
Loading