Skip to content

Commit

Permalink
feat: runner use new image (#3468)
Browse files Browse the repository at this point in the history
## Changes

Contributes to
https://linear.app/nango/issue/NAN-605/use-image-for-runner

- Runner: Use unified docker image
Tested in staging
https://dashboard.render.com/pserv/srv-cui9s49u0jms739cd95g/settings
It's less transparent since we need to specify a docker command, happy
to get suggestion here. I expect that after the migration, we can set it
as the default

- Fix deprecated runtime configuration
see doc https://api-docs.render.com/reference/create-service

- Remove docker login leftovers
  • Loading branch information
bodinsamuel authored Feb 7, 2025
1 parent c483bc1 commit bbd3721
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
25 changes: 1 addition & 24 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy jobs
run: |
SERVICE_ID=${{ fromJson('{ production: "srv-clvvtdug1b2c73cklps0", staging: "srv-clthttda73kc73ejflg0" }')[inputs.stage] }}
Expand All @@ -72,13 +68,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push tag
run: |
docker buildx imagetools create nangohq/nango-runner:${{ github.sha }} --tag nangohq/nango-runner:${{ inputs.stage }}
- name: Deploy all runners
env:
API_KEY: ${{ secrets.RENDER_API_KEY }}
Expand All @@ -90,18 +79,14 @@ jobs:
curl -sS --fail-with-body --request POST "https://$NANGO_API_HOSTNAME/internal/fleet/nango_runners/rollout" \
--header "authorization: Bearer $INTERNAL_API_KEY"\
--header "content-type: application/json"\
--data "{ \"image\": \"nangohq/nango-runner:${{ github.sha }}\" }"
--data "{ \"image\": \"nangohq/nango:${{ github.sha }}\" }"
deploy_persist:
if: inputs.service == 'persist'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy persist
run: |
SERVICE_ID=${{ fromJson('{ "production": "srv-cmt150ol6cac73apstq0", "staging": "srv-cmsfiqqcn0vc73bhcod0" }')[inputs.stage] }}
Expand All @@ -119,10 +104,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy orchestrator
run: |
SERVICE_ID=${{ fromJson('{ "production": "srv-cp6bhl0l6cac738i3dm0", "staging": "srv-cp5qedsf7o1s739kjqtg" }')[inputs.stage] }}
Expand All @@ -140,10 +121,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy connect
run: |
SERVICE_ID=${{ fromJson('{ "production": "srv-crtut51u0jms73bts8fg", "staging": "srv-crv6gi68ii6s738m8u90" }')[inputs.stage] }}
Expand Down
2 changes: 1 addition & 1 deletion packages/jobs/lib/runner/render.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class RenderAPI {
name: string;
ownerId: string;
image: { ownerId: string; imagePath: string };
serviceDetails: { env: string; plan: 'starter' | 'standard' | 'pro' };
serviceDetails: { runtime: 'image'; plan: 'starter' | 'standard' | 'pro' };
envVars: { key: string; value: string }[];
}): Promise<AxiosResponse> {
return await this.httpClient.post('/services', data);
Expand Down
11 changes: 8 additions & 3 deletions packages/jobs/lib/runner/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { setTimeout } from 'node:timers/promises';
const logger = getLogger('Render');

const render: RenderAPI = new RenderAPI(envs.RENDER_API_KEY || '');
const runnerPort = '80';

export const renderNodeProvider: NodeProvider = {
defaultNodeConfig: {
Expand All @@ -25,6 +26,7 @@ export const renderNodeProvider: NodeProvider = {
if (!envs.RUNNER_OWNER_ID) {
throw new Error('RUNNER_OWNER_ID is not set');
}

const ownerId = envs.RUNNER_OWNER_ID;
const name = serviceName(node);
const res = await withRateLimitHandling<{ service: { id: string; suspended: string } }>('create', () =>
Expand All @@ -34,11 +36,14 @@ export const renderNodeProvider: NodeProvider = {
ownerId,
image: { ownerId, imagePath: node.image },
serviceDetails: {
env: 'image',
plan: getPlan(node)
runtime: 'image',
plan: getPlan(node),
...(node.image.includes('-runner')
? {}
: { envSpecificDetails: { dockerCommand: `node packages/runner/dist/app.js ${runnerPort} dockerized-runner` } })
},
envVars: [
{ key: 'PORT', value: '80' },
{ key: 'PORT', value: runnerPort },
{ key: 'NODE_ENV', value: envs.NODE_ENV },
{ key: 'NANGO_CLOUD', value: String(envs.NANGO_CLOUD) },
{ key: 'NODE_OPTIONS', value: `--max-old-space-size=${Math.floor((node.memoryMb / 4) * 3)}` },
Expand Down

0 comments on commit bbd3721

Please sign in to comment.