Skip to content

Commit

Permalink
Add server setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano committed Jun 4, 2024
1 parent 02b27a4 commit 0b73bfa
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
site/
*html
src/hosts/*png
22 changes: 16 additions & 6 deletions build.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
;;; package -- Build script for wmedrano.dev
;;; Commentary:
;;; Builds wmedrano.dev website by converting .org files into html.
;;; emacs -Q --script build.el
;;; Code:
(require 'ox-publish)

Expand All @@ -16,11 +17,11 @@ The static site is output into the site directory."
")
(org-html-link-up "../") ;; Unused. Required for home/up to render.
(org-publish-project-alist
`(("wmedrano-site" :components ("wmedrano-home" "wmedrano-posts"))
`(("wmedrano-site" :components ("wmedrano-home" "wmedrano-posts" "wmedrano-hosts"))
("wmedrano-home"
:base-directory "./src"
:publishing-directory "./src"
:publishing-function org-html-publish-to-html
:publishing-directory "./site"
:recursive nil
:exclude ".*"
:include ("index.org" "about.org")
Expand All @@ -30,19 +31,28 @@ The static site is output into the site directory."
)
("wmedrano-posts"
:base-directory "./src/posts"
:publishing-directory "./src/posts"
:publishing-function org-html-publish-to-html
:publishing-directory "./site/posts"
:recursive t
:auto-sitemap t
:section-numbers nil
:sitemap-title "Posts"
:sitemap-filename "index.org"
:html-link-home "../"
)))
)
("wmedrano-hosts"
:base-directory "./src/hosts"
:publishing-function org-html-publish-to-html
:publishing-directory "./src/hosts"
:recursive nil
:auto-sitemap t
:section-numbers t
:sitemap-title "Hosts"
:sitemap-filename "index.org"
:html-link-home "../")))
(org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\"/>")
(org-html-validation-link nil))
(org-publish-project "wmedrano-site" t)
(copy-file "src/style.css" "site/style.css" t)))
(org-publish-project "wmedrano-site" t)))

(build-wmedrano-dev-site)

Expand Down
3 changes: 3 additions & 0 deletions src/hosts/index.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#+TITLE: Hosts

- [[file:oddtaxi.org][Odd Taxi]]
88 changes: 88 additions & 0 deletions src/hosts/oddtaxi.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#+TITLE: Odd Taxi
#+AUTHOR: Will S. Medrano

* Overview
:PROPERTIES:
:CUSTOM_ID: Overview-1nni0vb0x7k0
:END:

~oddtaxi~ is the main entry point to [[https://www.wmedrano.dev][wmedrano.dev]]. Requests from port
~80~ (http) and ~443~ (https) are intercepted by Caddy to either:

- Serve a static file.
- Reroute request to another job.

#+BEGIN_SRC dot :file oddtaxi.png
digraph oddtaxi {
node[shape=record];
blog -> caddy -> public_internet;
prometheus -> caddy;
}
#+END_SRC

#+RESULTS:
[[file:oddtaxi.png]]

* Configs
:PROPERTIES:
:CUSTOM_ID: Configs-whg458d0x7k0
:END:

** Caddy
:PROPERTIES:
:CUSTOM_ID: ConfigsCaddy-g8j458d0x7k0
:END:

#+BEGIN_SRC caddyfile :file /etc/caddy/Caddyfile :tangle yes
# Static files
wmedrano.dev {
root * /home/hiroshi/wmedrano.dev/src
file_server
}
www.wmedrano.dev {
root * /home/hiroshi/wmedrano.dev/src
file_server
}

# Prometheus
status.wmedrano.dev {
basicauth {
hiroshi $2a$14$gNmaQXMSBIbDkTyw5JgSPeWS1b99ueVHNiBNBzhk.y2YZ3yxYsHhq
}
reverse_proxy localhost:9090
}

# Serve Caddy prometheus metrics through localhost:21894.
:21894 {
metrics
}
#+END_SRC

** Prometheus
:PROPERTIES:
:CUSTOM_ID: ConfigsPrometheus-ywk458d0x7k0
:END:

#+BEGIN_SRC yaml :file /etc/prometheus/prometheus.yml :tangle yes
global:
# Set the scrape interval to every 15 seconds. Default is every 1 minute.
scrape_interval: 15s
# Evaluate rules every 15 seconds. The default is every 1 minute.
evaluation_interval: 15s
external_labels:
monitor: 'oddtaxi'
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: node
static_configs:
- targets: ['localhost:9100']
- job_name: caddy
static_configs:
- targets: ['localhost:21894']
#+END_SRC
3 changes: 3 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ body {
padding: 1rem;
font-family: verdana, sans;
}
a {
text-decoration: none;
}

0 comments on commit 0b73bfa

Please sign in to comment.