Skip to content

Commit

Permalink
Owl demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sourishkrout committed Nov 5, 2024
1 parent fdc18bf commit 09ad444
Show file tree
Hide file tree
Showing 12 changed files with 1,373 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DOCS_GCP_PROJECT_ID="runme-ci"
DOCS_GCP_REGION="us-central1"

GOAWAY=1
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DOCS_GCP_ARTIFACTS_REPO="Artifacts Docker repo in GCP" # Docs
DOCS_GCP_CREDENTIALS="Credentials for auth with GCP" # Docs
DOCS_GCP_PROJECT_ID="Project ID for deploy into GCP" # Docs
DOCS_GCP_REGION="Region for deploy into GCP" # Docs
45 changes: 45 additions & 0 deletions .runme/owl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: runme.stateful.com/v1beta1
kind: EnvSpecDefinitions
metadata:
name: docs.runme.dev
namespace: stateful
annotations:
github.com/repo-url: https://github.com/stateful/docs.runme.dev
spec:
type: owl
envSpecs:
- name: Docs
breaker: DOCS
atomics:
- key: GCP_ARTIFACTS_REPO
atomic: Opaque
rules: printascii
required: true
- key: GCP_CREDENTIALS
atomic: Secret
rules: json
required: true
- key: GCP_PROJECT_ID
atomic: Plain
rules: printascii
required: true
- key: GCP_REGION
atomic: Plain
rules: printascii
required: true
---
apiVersion: runme.stateful.com/v1beta1
kind: EnvResolution
metadata:
name: docs.runme.dev
namespace: stateful
annotations:
github.com/repo-url: https://github.com/stateful/docs.runme.dev
spec:
type: owl
path:
transform:
expr: key | trimPrefix("DOCS_GCP_") | lower()
gcp:
auth: ADC
project: runme-ci
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
"marquee.widgets.npm-stats.packageNames": [
"runme.dev"
],
// "runme.server.customAddress": "127.0.0.1:9999",
// "runme.server.tlsDir": "/tmp/runme/tls",
"runme.server.runnerVersion": "v1",
"runme.experiments.smartEnvStore": true,
}
18 changes: 18 additions & 0 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "docs.runme.dev",
"engineVersion": "v0.13.7",
"sdk": "typescript",
"dependencies": [
{
"name": "docusaurus",
"source": "github.com/levlaz/daggerverse/docusaurus@docusaurus/v0.7.0",
"pin": "f073c72e0a7345bba2173a15269307df297c3c13"
},
{
"name": "google-cloud-run",
"source": "github.com/vvaswani/daggerverse/google-cloud-run@google-cloud-run/v0.1.5",
"pin": "6e44ee4a901dda7d742574354132745701db3c52"
}
],
"source": "dagger"
}
1 change: 1 addition & 0 deletions dagger/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk/** linguist-generated
3 changes: 3 additions & 0 deletions dagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/sdk
/**/node_modules/**
/**/.pnpm-store/**
50 changes: 50 additions & 0 deletions dagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
cwd: ..
runme:
id: 01JBWW23ENADYZXX5KFGME12KR
terminalRows: 20
---

# The Docs, daggerized

See what functions are available in the `docs` module, and how to use them.

```sh {"id":"01JBW9KGZT5XE4B0G1Z8GK1239","terminalRows":"8"}
dagger functions
```

Inspect a local instance of the docs before deploying it to the cloud.

```sh {"background":"true","id":"01JBWGTT8R91VNCV1JSG8KF1K5","name":"serve-locally"}
dagger call --site . \
serve \
up
```

## Deploy a docs site preview

```sh {"id":"01JBWVFDXVDBBMRQAQA61NN6CB","name":"check","terminalRows":"3"}
echo "Deploying preview into \"${DOCS_GCP_PROJECT_ID}\" in \"${DOCS_GCP_REGION}\" from registry repo \"${DOCS_GCP_ARTIFACTS_REPO}\"."
```

This will deploy a preview of the docs site to the cloud.

```sh {"background":"false","id":"01JBWA2741XJE0KZZTGP7P1WKB","name":"DEPLOY_URL"}
dagger call --site . \
deploy \
--project="${DOCS_GCP_PROJECT_ID}" \
--region="${DOCS_GCP_REGION}" \
--repo="${DOCS_GCP_ARTIFACTS_REPO}" \
--credentials="env:DOCS_GCP_CREDENTIALS"
```

```sh {"id":"01JBWV44M5ZJCAERKS9E5KP7RS","interactive":"true"}
echo "Opening ${DEPLOY_URL}"
open ${DEPLOY_URL}
```

## See what services are running

```sh {"id":"01JBX0HGR3DBKSC6PJM57845EK"}
https://console.cloud.google.com/run?project=${DOCS_GCP_PROJECT_ID}
```
8 changes: 8 additions & 0 deletions dagger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "module",
"dependencies": {
"@dagger.io/dagger": "./sdk",
"typescript": "^5.5.4"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
66 changes: 66 additions & 0 deletions dagger/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* A generated module for DocsRunmeDev functions
*
* This module has been generated via dagger init and serves as a reference to
* basic module structure as you get started with Dagger.
*/
import { dag, Container, Directory, object, func, Docusaurus, Service, Secret, Platform } from "@dagger.io/dagger"

@object()
export class DocsRunmeDev {
site: Docusaurus

constructor(site: Directory) {
const disableCache = false
this.site = dag.docusaurus(site, { disableCache })
}

/**
* Returns a directory with a production-ready build of the docs site.
*/
@func()
build(): Directory {
return this.site
.build()
}

/**
* Build container serving a build of the docs site.
*/
@func()
async container(): Promise<Container> {
const platform = "linux/amd64" as Platform
return (
dag.container({ platform })
.from("nginx:1.27.2-alpine-slim")
.withDirectory("/usr/share/nginx/html", this.site.build())
.withExposedPort(80)
)
}

/**
* Bring up container serving a build of the docs site.
*/
@func()
async serve(): Promise<Service> {
const container = await this.container()
return container.asService()
}

protected async publish(imageRef: string): Promise<string> {
const image = await this.container()
return image.publish(imageRef)
}

/**
* Deploy docs site container image to Google Cloud Run.
*/
@func()
async deploy(project: string, region: string, repo: string, credentials: Secret): Promise<string> {
const imageRef = await this.publish(`${region}-docker.pkg.dev/${project}/${repo}/site:lastest`)

return dag
.googleCloudRun()
.createService("runme-ci", "us-central1", imageRef, 80, credentials)
}
}
11 changes: 11 additions & 0 deletions dagger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ES2022",
"moduleResolution": "Node",
"experimentalDecorators": true,
"paths": {
"@dagger.io/dagger": ["./sdk"],
"@dagger.io/dagger/telemetry": ["./sdk/telemetry"]
}
}
}
Loading

0 comments on commit 09ad444

Please sign in to comment.