From b6cc29114a448386356418cebbff35ca4793cd63 Mon Sep 17 00:00:00 2001 From: m1ka Date: Sun, 5 Apr 2026 17:33:41 +0200 Subject: [PATCH] dockerise the building/running of www --- .gitmodules | 3 +++ Dockerfile | 39 +++++++++++++++++++++++++++++++++ README.md | 7 ++++++ fxg | 1 + kethel/main.exs | 50 ++++++++++++++++++++++++------------------ nginx.conf | 29 +++++++++++++++++++++++++ pages/colophon.fxg | 4 ++-- pages/colophon.html | 52 -------------------------------------------- pages/index.fxg | 18 +++++---------- pages/index.html | 53 --------------------------------------------- pages/projects.fxg | 8 +++---- pages/projects.html | 52 -------------------------------------------- pastes/main.rs | 3 --- 13 files changed, 120 insertions(+), 199 deletions(-) create mode 100644 .gitmodules create mode 100644 Dockerfile create mode 160000 fxg create mode 100644 nginx.conf delete mode 100644 pages/colophon.html delete mode 100644 pages/index.html delete mode 100644 pages/projects.html delete mode 100644 pastes/main.rs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..0b2dfb2b56fbac4cbd87cd3547f4c08a4e02fc4d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "fxg"] + path = fxg + url = https://codeberg.org/m1ka/fxg.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a8d2aa18b6482f84c706ed3e53f474b3445d9e09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +FROM alpine:3 +RUN apk add --no-cache elixir nginx git rust cargo nodejs npm +COPY nginx.conf /etc/nginx/nginx.conf + +# setup folders +RUN mkdir -p /data/www +RUN adduser -D -g 'www' www +RUN chown -R www:www /var/lib/nginx + +# build fxg +WORKDIR "/usr/local/fxg" +COPY fxg . +RUN cargo build --release +RUN cp target/release/fxg /usr/local/bin + +# fetch deps +WORKDIR "/usr/local/app" +COPY pull-hljs.sh . +RUN ./pull-hljs.sh +WORKDIR "/usr/local/app/kethel" +COPY kethel/mix.exs kethel/mix.lock kethel/package.json kethel/package-lock.json . +RUN npm i + +# build www.m1kadev.nl +WORKDIR "/usr/local/app" +COPY . . +WORKDIR "/usr/local/app/kethel" +RUN mix deps.get +RUN mix compile.rambo +RUN mix run main.exs -- .. +WORKDIR "/usr/local/app" +RUN cp -r build/* /data/www +WORKDIR "/data/www" + +RUN chown -R www:www /data/www +RUN chmod -R 744 /data/www + +# serve www.m1kadev.nl +CMD [ "nginx", "-c", "/etc/nginx/nginx.conf" ] \ No newline at end of file diff --git a/README.md b/README.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a51f64359f36bd35d384564829537f7691dc3f32 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,7 @@ +====== www.m1kadev.nl ====== + +===== Running ===== + +This should work out of the box: + docker build -t 'www.m1kadev.nl' . + docker run -d -p 8080:8080 'www.m1kadev.nl' diff --git a/fxg b/fxg new file mode 160000 index 0000000000000000000000000000000000000000..61eb93988888de008c12e2fee91d079a91c69b7f --- /dev/null +++ b/fxg @@ -0,0 +1 @@ +Subproject commit 61eb93988888de008c12e2fee91d079a91c69b7f diff --git a/kethel/main.exs b/kethel/main.exs index 85d67f08c7ed48e5a82f777a9720136cd92f6ed7..2408c9d0dca3074f523af7e29f6c0ef17bba5fcc 100644 --- a/kethel/main.exs +++ b/kethel/main.exs @@ -27,21 +27,23 @@ if folder != nil do collection_time_end = System.monotonic_time(:millisecond) compilation_time_start = System.monotonic_time(:millisecond) - + pages_compile_task = Task.async(fn -> Pages.compile(pages) end) styles_compile_task = Task.async(fn -> Styles.compile(styles) end) scripts_compile_task = Task.async(fn -> Scripts.compile(scripts) end) thoughts_compile_task = Task.async(fn -> Thoughts.compile(thoughts) end) - [ pages_time, styles_time, scripts_time, thoughts_time] = Task.await_many( - [ - pages_compile_task, - styles_compile_task, - scripts_compile_task, - thoughts_compile_task - ], - :infinity - ) + [pages_time, styles_time, scripts_time, thoughts_time, statics] = + Task.await_many( + [ + pages_compile_task, + styles_compile_task, + scripts_compile_task, + thoughts_compile_task, + statics_task + ], + :infinity + ) compilation_time_end = System.monotonic_time(:millisecond) @@ -49,21 +51,22 @@ if folder != nil do rss_footer = "" rss_item_template = File.read!("#{project_root}/rss/item.txml") - rss_thoughts = thoughts.thoughts + rss_thoughts = + thoughts.thoughts |> Enum.take(10) |> Enum.map(fn thought -> Thoughts.to_rss(thought, rss_item_template, project_root) end) - |> Enum.join(); + |> Enum.join() File.write!("#{project_root}/build/rss.xml", rss_header <> rss_thoughts <> rss_footer) IO.puts("[COMPILED] #{project_root}/build/rss.xml") - - { lcss_version, 0 }= System.cmd("npx", [ "lightningcss", "-V" ]) - { hmn_version, 0 } = System.cmd("npx", [ "html-minifier-next", "-V" ]) - { ujs_version, 0 } = System.cmd("npx", [ "uglifyjs", "-V" ]) - { git_commit, 0 } = System.cmd("git", [ "rev-parse", "HEAD" ]) - { build_date, 0 } = System.cmd("date", ["+%H:%M %d/%m/%y"]) + {lcss_version, 0} = System.cmd("npx", ["lightningcss", "-V"]) + {hmn_version, 0} = System.cmd("npx", ["html-minifier-next", "-V"]) + {ujs_version, 0} = System.cmd("npx", ["uglifyjs", "-V"]) + {git_commit, 0} = System.cmd("git", ["rev-parse", "HEAD"]) + + {build_date, 0} = System.cmd("date", ["+%H:%M %d/%m/%y"]) info_txt = """ commit=#{git_commit} @@ -72,17 +75,22 @@ if folder != nil do uglifyjs=#{ujs_version} build_time=#{build_date} """ - + File.write!("#{project_root}/build/info.txt", info_txt) IO.puts("[COMPILED] #{project_root}/build/info.txt") - IO.puts("Finalising..."); + IO.puts("Finalising...") File.cp!("#{project_root}/favicon.ico", "#{project_root}/build/favicon.ico") IO.puts("") IO.puts(:stderr, "===== BUILD RESULTS =====") - IO.puts(:stderr, "FILE READING (*.collect()) | #{collection_time_end - collection_time_start}ms") + + IO.puts( + :stderr, + "FILE READING (*.collect()) | #{collection_time_end - collection_time_start}ms" + ) + IO.puts(:stderr, "Root page (compile) | #{pages_time}ms") IO.puts(:stderr, "Styles (compile) | #{styles_time}ms") IO.puts(:stderr, "Scripts (compile) | #{scripts_time}ms") diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..5033c47dd723162be413369dd9a207cb5976aa0d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,29 @@ +user www; +worker_processes auto; + +daemon off; + +error_log /var/log/nginx/error.log warn; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + sendfile on; + access_log /var/log/nginx/access.log; + keepalive_timeout 3000; + server { + listen 8080; + root /data/www; + index index.html; + server_name localhost; + client_max_body_size 32m; + error_page 500 502 503 503 /50x.html; + location = /50x.html { + root /var/lib/nginx/html; + } + } +} \ No newline at end of file diff --git a/pages/colophon.fxg b/pages/colophon.fxg index 4402fdf79aa7ef3b7b87daa17017b55a911b3a18..67abc0cc75e355e1fbf009de34df3f737d987fef 100644 --- a/pages/colophon.fxg +++ b/pages/colophon.fxg @@ -1,6 +1,6 @@ -= colophon = +====== colophon ====== -== about == +===== about ===== you're looking at a <#https://en.wiktionary.org/wiki/beautiful#English beautiful> site, with <#https://caddyserver.com/ caddy> as its backend. diff --git a/pages/colophon.html b/pages/colophon.html deleted file mode 100644 index ad3e85b7248bb7a3334d7be5ad985e67a4d5fbf6..0000000000000000000000000000000000000000 --- a/pages/colophon.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - home - m1kadev - - - -
-
-

colophon

about

you're looking at a beautiful site, with caddy as its backend. all source pages are written in my own markup language, fxg. site generation is done by a homebrewn elixir script. all code (including fxg) is licenced under the MIT licence. -
-
-
-

Deployed from commit , on

-
-
- - GitHub logo - -
-
-
-
- -
-

.nl

-

m1kadev

- -
- - - - \ No newline at end of file diff --git a/pages/index.fxg b/pages/index.fxg index edeff76f2fb4256cbd6e65cf368c9443f739b0f5..dccaa199393859a706da3c0eab89bc2d2ded9b39 100644 --- a/pages/index.fxg +++ b/pages/index.fxg @@ -1,17 +1,11 @@ -= haii :3 i'm mika = +====== haii :3 i'm mika ====== -haiii!!! i'm mika (also //m1ka//, //m1kadev//). i'm a (mostly backend) developer from <#https://en.wikipedia.org/wiki/Nederland The Netherlands>. i'm also a big fan of making drinks & cooking. +haii! i'm mika (also //m1ka//, //m1kadev//). i'm a (mostly backend) developer from <#https://wikipedia.org/wiki/The_Netherlands The Netherlands>. besides programming, i also like to play music and cook. -=== about me === +===== about me ===== -i do VWO (dutch A-levels) phyiscs in the greater rotterdam area. i've been working on <#https://www.github.com/m1kadev/fxg fxg>, a markup language written in <#https://rust-lang.org/ Rust>. also, i've been playing around with functional programming (mostly in <#https://elixir-lang.org Elixir>). +i do VWO (dutch a-levels) physics, in the greater rotterdam area. i enjoy implementing things from scratch. this website is made with <#https://codeberg.org/m1ka/fxg a custom markup language>, writen in rust, using <#https://codeberg.org/m1ka/www.m1kadev.nl/ a custom build system>, written in elixir. -Together with 3 other friends, we run <#https://dupunkto.org/ {du}punkto> +===== contact ===== -=== contact === -feel free to reach out to me! you can reach me at m1kadev on <#https://discord.com/ discord>, or on my email address at - - -format!("{2}@{0}.{1}", "dupunkto", "org", "mika") - -??this code is to filter out all non-<>format! users?? \ No newline at end of file +feel free to reach out to me! i'm available at m1kadev on discord, or otherwise on my e-mail, "mika [dot] dupunkto [at] org". (you're not stupid; i think you know what characters go where). \ No newline at end of file diff --git a/pages/index.html b/pages/index.html deleted file mode 100644 index 9167ad3477d4401dd38392f96a2e790e4b397bb6..0000000000000000000000000000000000000000 --- a/pages/index.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - home - m1kadev - - - -
-
-

haii :3 i'm mika

haiii!!! i'm mika (also m1ka, m1kadev). i'm a (mostly backend) developer from The Netherlands. i'm also a big fan of making drinks & cooking.

about me

i do VWO (dutch A-levels) phyiscs in the greater rotterdam area. i've been working on fxg, a markup language written in Rust. also, i've been playing around with functional programming (mostly in Elixir).
Together with 3 other friends, we run {du}punkto

contact

feel free to reach out to me! you can reach me at m1kadev on discord, or on my email address at
format!("{2}@{0}.{1}", "dupunkto", "org", "mika")
-
this code is to filter out all non-format! users -
-
-
-

Deployed from commit , on

-
-
- - GitHub logo - -
-
-
-
- -
-

.nl

-

m1kadev

- -
- - - - \ No newline at end of file diff --git a/pages/projects.fxg b/pages/projects.fxg index 08245782fdad4630720064db050c984c0c13a21b..935818aead6755e4cf74dbe9906aad59396db915 100644 --- a/pages/projects.fxg +++ b/pages/projects.fxg @@ -1,8 +1,8 @@ -= projects = +====== projects ====== -=== fxg === +===== fxg ===== <#https://github.com/m1kadev/fxg fxg> is my own markup language, written in <#https://rust-lang.org/ Rust>. it aims to maximise readability in text form, and tries to only have one way to write markup (unlike Markdown). you can view <#https://github.com/m1kadev/www.m1kadev.nl/blob/main/src/projects.fxg the source> of this page, if you'd like to see for yourself. -=== m1kadev.nl === -the site you're on right now! the <#https://github.com/m1kadev/www.m1kadev.nl/blob/main/build.exs generator> for this site is written in elixir. all code for the generator (besides <#https://hexdocs.pm/tzdata/readme.html Tzdata>, for the build timestamp) is written by me. \ No newline at end of file +===== m1kadev.nl ===== +the site you're on right now! the <#https://github.com/m1kadev/www.m1kadev.nl/blob/main/build.exs generator> for this site is written in elixir. all code for the generator (besides <#https://hexdocs.pm/tzdata/readme.html Tzdata>, for the build timestamp) is written by me. diff --git a/pages/projects.html b/pages/projects.html deleted file mode 100644 index 00c1a8b47e4fe819b4818a2544cd5127424c5dec..0000000000000000000000000000000000000000 --- a/pages/projects.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - home - m1kadev - - - -
-
-

projects

fxg

fxg is my own markup language, written in Rust. it aims to maximise readability in text form, and tries to only have one way to write markup (unlike Markdown). you can view the source of this page, if you'd like to see for yourself.

m1kadev.nl

the site you're on right now! the generator for this site is written in elixir. all code for the generator (besides Tzdata, for the build timestamp) is written by me. -
-
-
-

Deployed from commit , on

-
-
- - GitHub logo - -
-
-
-
- -
-

.nl

-

m1kadev

- -
- - - - \ No newline at end of file diff --git a/pastes/main.rs b/pastes/main.rs deleted file mode 100644 index e7a11a969c037e00a796aafeff6258501ec15e9a..0000000000000000000000000000000000000000 --- a/pastes/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -}