Skip to content

Commit

Permalink
ops: create dedicated servers for GitHub workers
Browse files Browse the repository at this point in the history
Environment groups are commented in a first step, because Render doesn't support environments in blueprints.

So we need to create the services first, move them manually from the UI to the right environement and *then* attach their environment groups.
  • Loading branch information
frankie567 committed Nov 22, 2024
1 parent 5ed1115 commit 339b7a2
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 22 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/deploy_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@
set -euo pipefail

IMG="ghcr.io/polarsource/polar@${1}"
declare -A servers=(
["srv-ci4r87h8g3ne0dmvvl60"]="${RENDER_DEPLOY_KEY_API}"
["srv-csth45d6l47c73ekphf0"]="${RENDER_DEPLOY_KEY_WORKER}"
["srv-crkocgbtq21c73ddsdbg"]="${RENDER_DEPLOY_KEY_API_SANDBOX}"
["srv-csth45d6l47c73ekphdg"]="${RENDER_DEPLOY_KEY_WORKER_SANDBOX}"
)

# Deploy api
curl -X POST \
for server_id in "${!servers[@]}"; do
deploy_key=${servers[$server_id]}
curl -X POST \
--silent --show-error --fail-with-body \
"https://api.render.com/deploy/srv-ci4r87h8g3ne0dmvvl60?key=${RENDER_DEPLOY_KEY_API}&imgURL=${IMG}"

# Deploy worker
curl -X POST \
--silent --show-error --fail-with-body \
"https://api.render.com/deploy/srv-csth45d6l47c73ekphf0?key=${RENDER_DEPLOY_KEY_WORKER}&imgURL=${IMG}"

# Deploy api-sandbox
curl -X POST \
--silent --show-error --fail-with-body \
"https://api.render.com/deploy/srv-crkocgbtq21c73ddsdbg?key=${RENDER_DEPLOY_KEY_API_SANDBOX}&imgURL=${IMG}"

# Deploy worker-sandbox
curl -X POST \
--silent --show-error --fail-with-body \
"https://api.render.com/deploy/srv-csth45d6l47c73ekphdg?key=${RENDER_DEPLOY_KEY_WORKER_SANDBOX}&imgURL=${IMG}"
"https://api.render.com/deploy/${server_id}?key=${deploy_key}&imgURL=${IMG}"
done
108 changes: 104 additions & 4 deletions render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ services:
- fromGroup: stripe-production
- fromGroup: logfire-server

# Worker
# Workers
- type: worker
name: worker
runtime: image
Expand All @@ -79,7 +79,7 @@ services:
fromRegistryCreds:
name: Registry Credentials (by fvoron)
plan: standard
dockerCommand: uv run python -m run_worker --default-worker-num 2
dockerCommand: uv run python -m run_worker --worker-num 2 --scheduler default
region: ohio
numInstances: 1
autoDeploy: false # deploys are triggered by github actions
Expand Down Expand Up @@ -122,6 +122,57 @@ services:
- fromGroup: stripe-production
- fromGroup: logfire-worker

- type: worker
name: worker-github
runtime: image
image:
url: ghcr.io/polarsource/polar:latest
creds:
fromRegistryCreds:
name: Registry Credentials (by fvoron)
plan: starter
dockerCommand: uv run python -m run_worker github
region: ohio
numInstances: 1
autoDeploy: false # deploys are triggered by github actions
envVars:
- key: POLAR_POSTGRES_DATABASE
fromDatabase:
name: db
property: database
- key: POLAR_POSTGRES_HOST
fromDatabase:
name: db
property: host
- key: POLAR_POSTGRES_PORT
fromDatabase:
name: db
property: port
- key: POLAR_POSTGRES_PWD
fromDatabase:
name: db
property: password
- key: POLAR_POSTGRES_USER
fromDatabase:
name: db
property: user
- key: POLAR_REDIS_HOST
fromService:
type: redis
name: redis
property: host
- key: POLAR_REDIS_PORT
fromService:
type: redis
name: redis
property: port
- key: POLAR_REDIS_DB
value: 0
# - fromGroup: google-production
# - fromGroup: github-production
# - fromGroup: backend-production
# - fromGroup: stripe-production

- type: redis
name: redis
plan: standard
Expand Down Expand Up @@ -195,7 +246,7 @@ services:
- fromGroup: backend-sandbox
- fromGroup: stripe-sandbox

# Worker
# Workers
- type: worker
name: worker-sandbox
runtime: image
Expand All @@ -205,7 +256,7 @@ services:
fromRegistryCreds:
name: Registry Credentials (by fvoron)
plan: standard
dockerCommand: uv run python -m run_worker --default-worker-num 2
dockerCommand: uv run python -m run_worker --worker-num 2 --scheduler default
region: ohio
numInstances: 1
autoDeploy: false # deploys are triggered by github actions
Expand Down Expand Up @@ -245,6 +296,55 @@ services:
- fromGroup: backend-sandbox
- fromGroup: stripe-sandbox

- type: worker
name: worker-github-sandbox
runtime: image
image:
url: ghcr.io/polarsource/polar:latest
creds:
fromRegistryCreds:
name: Registry Credentials (by fvoron)
plan: standard
dockerCommand: uv run python -m run_worker github
region: ohio
numInstances: 1
autoDeploy: false # deploys are triggered by github actions
envVars:
- key: POLAR_POSTGRES_DATABASE
value: polar_sandbox
- key: POLAR_POSTGRES_HOST
fromDatabase:
name: db
property: host
- key: POLAR_POSTGRES_PORT
fromDatabase:
name: db
property: port
- key: POLAR_POSTGRES_PWD
fromDatabase:
name: db
property: password
- key: POLAR_POSTGRES_USER
fromDatabase:
name: db
property: user
- key: POLAR_REDIS_HOST
fromService:
type: redis
name: redis
property: host
- key: POLAR_REDIS_PORT
fromService:
type: redis
name: redis
property: port
- key: POLAR_REDIS_DB
value: 1
# - fromGroup: google-sandbox
# - fromGroup: github-sandbox
# - fromGroup: backend-sandbox
# - fromGroup: stripe-sandbox

databases:
- name: db
databaseName: polar_cpit
Expand Down

0 comments on commit 339b7a2

Please sign in to comment.