Pulumi code for my server setup
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

use github API using gh CLI to get repo commits

+26 -36
+5 -5
lib/service/service.ts
··· 4 4 import type { input } from "@pulumi/command/types"; 5 5 import { Container, type ContainerArgs, getRegistryImage, RemoteImage } from "@pulumi/docker"; 6 6 import type { 7 - ContainerCapabilities, 8 - ContainerLabel, 9 - ContainerMount, 10 - ContainerPort, 11 - ContainerVolume, 7 + ContainerCapabilities, 8 + ContainerLabel, 9 + ContainerMount, 10 + ContainerPort, 11 + ContainerVolume, 12 12 } from "@pulumi/docker/types/output"; 13 13 import type { CustomResourceOptions, Input, InvokeOptions, Output, Resource } from "@pulumi/pulumi"; 14 14 import { all, ComponentResource, output } from "@pulumi/pulumi";
+7 -3
lib/util.ts
··· 4 4 import ky from "ky"; 5 5 import z from "zod"; 6 6 7 - export async function getLatestCommit(url: string) { 8 - const html = await ky.get(url, { retry: 5 }).text(); 7 + export async function getLatestTangledCommit(url: string) { 8 + const html = await ky(url, { retry: 5 }).text(); 9 9 const commit = html.match(/\/commit\/(\w+)/)?.[1]; 10 10 return commit; 11 11 } ··· 18 18 ) 19 19 .min(1); 20 20 21 - export async function getLatestTag(repo: string) { 21 + export async function getLatestGithubTag(repo: string) { 22 22 const githubApiToken = await $`gh auth token`.text(); 23 23 const githubApi = ky.create({ 24 24 headers: { ··· 31 31 const json = await githubApi(url, { retry: 5 }).json(GithubReleaseSchema); 32 32 assert(json[0]); 33 33 return json[0].name; 34 + } 35 + 36 + export async function getGithubContents(repo: string, dir?: string) { 37 + return await $`gh api repos/${repo}/contents/${dir ?? ""}`.json(); 34 38 } 35 39 36 40 export function ensure<T>(arg: T): NonNullable<T> {
+4 -10
services/haring/atproto/relay.ts
··· 1 1 import dockerBuild from "@pulumi/docker-build"; 2 2 import { interpolate } from "@pulumi/pulumi"; 3 3 import { getEnv } from "~lib/env"; 4 - import { confMount, dataMount, nvmeMount } from "~lib/service/mounts"; 4 + import { confMount, nvmeMount } from "~lib/service/mounts"; 5 5 import { defaultNetwork } from "~lib/service/networks"; 6 6 import { ContainerService } from "~lib/service/service"; 7 - import { getLatestCommit } from "~lib/util"; 7 + import { getGithubContents } from "~lib/util"; 8 8 9 9 import { STATIC_IPS } from "../ips"; 10 10 import { unboundService } from "../networking/unbound/unbound"; ··· 32 32 buildArgs: { 33 33 BUILDKIT_CONTEXT_KEEP_GIT_DIR: "true", 34 34 }, 35 - exports: [ 36 - { 37 - docker: {}, 38 - }, 39 - ], 35 + exports: [{ docker: {} }], 40 36 push: false, 41 37 buildOnPreview: false, 42 38 }, 43 39 { 44 - // replacementTrigger: await getLatestCommit( 45 - // "https://github.com/bluesky-social/indigo/commits/main/cmd/relay", 46 - // ), 40 + replacementTrigger: await getGithubContents("bluesky-social/indigo", "cmd/relay"), 47 41 }, 48 42 ); 49 43
+3 -7
services/haring/atproto/tangled/knot.ts
··· 5 5 import { getEnv } from "~lib/env"; 6 6 import { confMount, mount, nvmeMount } from "~lib/service/mounts"; 7 7 import { ContainerService, defaultConnection } from "~lib/service/service"; 8 - import { getLatestCommit } from "~lib/util"; 8 + import { getLatestTangledCommit } from "~lib/util"; 9 9 10 10 const knotImage = new Image( 11 11 "knot", ··· 19 19 buildArgs: { 20 20 BUILDKIT_CONTEXT_KEEP_GIT_DIR: "true", 21 21 }, 22 - exports: [ 23 - { 24 - docker: {}, 25 - }, 26 - ], 22 + exports: [{ docker: {} }], 27 23 push: false, 28 24 buildOnPreview: false, 29 25 }, 30 26 { 31 - replacementTrigger: await getLatestCommit( 27 + replacementTrigger: await getLatestTangledCommit( 32 28 "https://tangled.org/bas.sh/knot-docker/commits/fork", 33 29 ), 34 30 },
+3 -7
services/haring/atproto/tangled/spindle.ts
··· 3 3 import { getEnv } from "~lib/env"; 4 4 import { dockerSocketRw, nvmeMount } from "~lib/service/mounts"; 5 5 import { ContainerService } from "~lib/service/service"; 6 - import { getLatestCommit } from "~lib/util"; 6 + import { getLatestTangledCommit } from "~lib/util"; 7 7 8 8 const spindleImage = new Image( 9 9 "spindle", ··· 17 17 buildArgs: { 18 18 BUILDKIT_CONTEXT_KEEP_GIT_DIR: "true", 19 19 }, 20 - exports: [ 21 - { 22 - docker: {}, 23 - }, 24 - ], 20 + exports: [{ docker: {} }], 25 21 push: false, 26 22 buildOnPreview: false, 27 23 }, 28 24 { 29 - replacementTrigger: await getLatestCommit( 25 + replacementTrigger: await getLatestTangledCommit( 30 26 "https://tangled.org/bas.sh/knot-docker/commits/fork", 31 27 ), 32 28 },
+2 -2
services/haring/atproto/tranquil/tranquil.ts
··· 8 8 import { fetchRelays } from "~lib/relay-hosts"; 9 9 import { _mount, confMount, mount } from "~lib/service/mounts"; 10 10 import { ContainerService, defaultConnection } from "~lib/service/service"; 11 - import { getLatestCommit } from "~lib/util"; 11 + import { getLatestTangledCommit } from "~lib/util"; 12 12 13 13 const tranquilImage = new dockerBuild.Image( 14 14 "tranquil-pds", ··· 25 25 buildOnPreview: false, 26 26 }, 27 27 { 28 - replacementTrigger: await getLatestCommit( 28 + replacementTrigger: await getLatestTangledCommit( 29 29 "https://tangled.org/tranquil.farm/tranquil-pds/commits/main", 30 30 ), 31 31 customTimeouts: {
+2 -2
services/haring/other/sccache.ts
··· 5 5 import { getEnv } from "~lib/env"; 6 6 import { defaultNetwork } from "~lib/service/networks"; 7 7 import { ContainerService } from "~lib/service/service"; 8 - import { getLatestTag } from "~lib/util"; 8 + import { getLatestGithubTag } from "~lib/util"; 9 9 10 10 import { STATIC_IPS } from "../ips"; 11 11 ··· 15 15 location: path.join(import.meta.dirname, "sccache"), 16 16 }, 17 17 buildArgs: { 18 - VERSION: getLatestTag("mozilla/sccache"), 18 + VERSION: getLatestGithubTag("mozilla/sccache"), 19 19 }, 20 20 exports: [ 21 21 {