aboutsummaryrefslogtreecommitdiff
path: root/cmd/within.website
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/within.website')
-rw-r--r--cmd/within.website/main.go16
-rw-r--r--cmd/within.website/manifest.yaml150
-rw-r--r--cmd/within.website/yeetfile.js37
3 files changed, 163 insertions, 40 deletions
diff --git a/cmd/within.website/main.go b/cmd/within.website/main.go
index f7d20c5..8bb5c75 100644
--- a/cmd/within.website/main.go
+++ b/cmd/within.website/main.go
@@ -51,14 +51,14 @@ func (r Repo) LogValue() slog.Value {
)
}
-func (r Repo) RegisterHandlers(lg *slog.Logger) {
+func (r Repo) RegisterHandlers(mux *http.ServeMux, lg *slog.Logger) {
switch r.Kind {
case "gitea":
- http.Handle("/"+r.Repo, vanity.GogsHandler(*domain+"/"+r.Repo, r.Domain, r.User, r.Repo, "https"))
- http.Handle("/"+r.Repo+"/", vanity.GogsHandler(*domain+"/"+r.Repo, r.Domain, r.User, r.Repo, "https"))
+ mux.Handle("/"+r.Repo, vanity.GogsHandler(*domain+"/"+r.Repo, r.Domain, r.User, r.Repo, "https"))
+ mux.Handle("/"+r.Repo+"/", vanity.GogsHandler(*domain+"/"+r.Repo, r.Domain, r.User, r.Repo, "https"))
case "github":
- http.Handle("/"+r.Repo, vanity.GitHubHandler(*domain+"/"+r.Repo, r.User, r.Repo, "https"))
- http.Handle("/"+r.Repo+"/", vanity.GitHubHandler(*domain+"/"+r.Repo, r.User, r.Repo, "https"))
+ mux.Handle("/"+r.Repo, vanity.GitHubHandler(*domain+"/"+r.Repo, r.User, r.Repo, "https"))
+ mux.Handle("/"+r.Repo+"/", vanity.GitHubHandler(*domain+"/"+r.Repo, r.User, r.Repo, "https"))
}
lg.Debug("registered repo handler", "repo", r)
}
@@ -76,12 +76,12 @@ func main() {
os.Exit(1)
}
+ mux := http.NewServeMux()
+
for _, repo := range repos {
- repo.RegisterHandlers(lg)
+ repo.RegisterHandlers(mux, lg)
}
- mux := http.NewServeMux()
-
xess.Mount(mux)
mux.HandleFunc("/debug/varz", tsweb.VarzHandler)
diff --git a/cmd/within.website/manifest.yaml b/cmd/within.website/manifest.yaml
new file mode 100644
index 0000000..e0e915f
--- /dev/null
+++ b/cmd/within.website/manifest.yaml
@@ -0,0 +1,150 @@
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: within-website
+data:
+ "config.ts": |
+ export interface Repo {
+ kind: "gitea" | "github";
+ domain: string;
+ user: string;
+ repo: string;
+ description: string;
+ }
+
+ const githubRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "github",
+ domain: "github.com",
+ user: "Xe",
+ repo: name,
+ description,
+ };
+ };
+
+ const giteaRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "gitea",
+ domain: "tulpa.dev",
+ user: "cadey",
+ repo: name,
+ description,
+ };
+ };
+
+ const repos: Repo[] = [
+ githubRepo("derpigo", "A Derpibooru/Furbooru API client in Go. This is used to monitor Derpibooru/Furbooru for images by artists I care about and archive them."),
+ githubRepo("eclier", "A command router for Go programs that implements every command in Lua. This was an experiment for making extensible command-line applications with Lua for extending them."),
+ githubRepo("gcss", "A CSS preprocessor for Go. This is a legacy Go package that I am bringing forward to modern Go standards."),
+ giteaRepo("gopher", "A Gopher (RFC 1436) client/server stack for Go applications. This allows users to write custom Gopher clients and servers."),
+ githubRepo("ln", "The natural log function for Go: an easy package for structured logging. This is the logging stack that I use for most of my personal projects."),
+ githubRepo("x", "Various experimental things. /x/ is my monorepo of side projects, hobby programming, and other explorations of how programming in Go can be."),
+ ];
+
+ export default repos;
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: within-website
+ labels:
+ app.kubernetes.io/name: within-website
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app.kubernetes.io/name: within-website
+ template:
+ metadata:
+ labels:
+ app.kubernetes.io/name: within-website
+ spec:
+ securityContext:
+ fsGroup: 1000
+ volumes:
+ - name: tyson
+ configMap:
+ name: within-website
+ containers:
+ - name: main
+ image: ghcr.io/xe/x/within-website:latest
+ imagePullPolicy: "Always"
+ resources:
+ limits:
+ cpu: "500m"
+ memory: "256Mi"
+ requests:
+ cpu: "250m"
+ memory: "128Mi"
+ securityContext:
+ runAsUser: 1000
+ runAsGroup: 1000
+ runAsNonRoot: true
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop:
+ - ALL
+ seccompProfile:
+ type: RuntimeDefault
+ livenessProbe:
+ httpGet:
+ path: /
+ port: 8080
+ httpHeaders:
+ - name: X-Kubernetes
+ value: "is kinda okay"
+ initialDelaySeconds: 3
+ periodSeconds: 3
+ env:
+ - name: TYSON_CONFIG
+ value: "/etc/within.website/config.ts"
+ - name: PORT
+ value: "8080"
+ - name: SLOG_LEVEL
+ value: DEBUG
+ volumeMounts:
+ - name: tyson
+ mountPath: /etc/within.website
+ readOnly: true
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: within-website
+ labels:
+ app.kubernetes.io/name: within-website
+spec:
+ selector:
+ app.kubernetes.io/name: within-website
+ ports:
+ - port: 80
+ targetPort: 8080
+ name: http
+ type: ClusterIP
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: within-website
+ labels:
+ app.kubernetes.io/name: within-website
+ annotations:
+ cert-manager.io/cluster-issuer: "letsencrypt-prod"
+spec:
+ ingressClassName: nginx
+ tls:
+ - hosts:
+ - within.website
+ secretName: within-website-public-tls
+ rules:
+ - host: within.website
+ http:
+ paths:
+ - pathType: Prefix
+ path: "/"
+ backend:
+ service:
+ name: within-website
+ port:
+ name: http
diff --git a/cmd/within.website/yeetfile.js b/cmd/within.website/yeetfile.js
index b79868c..85abcf1 100644
--- a/cmd/within.website/yeetfile.js
+++ b/cmd/within.website/yeetfile.js
@@ -1,33 +1,6 @@
-yeet.setenv("GOOS", "linux");
-yeet.setenv("GOARCH", "amd64");
-yeet.setenv("CGO_ENABLED", "0");
+nix.build(".#docker.within-website");
+docker.load("./result");
+docker.push(`ghcr.io/xe/x/within-website`);
+yeet.run("kubectl", "apply", "-f=manifest.yaml");
+yeet.run("sh", "-c", "kubectl rollout restart deployments/within-website");
-go.build();
-const fname = slug.build("within.website", {
- "config.ts": "config.ts"
-});
-
-const url = slug.push(fname);
-const hash = nix.hashURL(url);
-
-const expr = nix.expr`{ stdenv }:
-
-stdenv.mkDerivation {
- name = "within.website";
- src = builtins.fetchurl {
- url = ${url};
- sha256 = ${hash};
- };
-
- phases = "installPhase";
-
- installPhase = ''
- tar xf $src
- mkdir -p $out/bin
- cp bin/main $out/bin/withinwebsite
- cp config.ts $out/config.ts
- '';
-}
-`;
-
-file.write("/home/cadey/code/nixos-configs/pkgs/x/withinwebsite.nix", expr);