~mika/www.m1kadev.nl

b6cc29114a448386356418cebbff35ca4793cd63 — m1ka 3 months ago 378090f
dockerise the building/running of www
13 files changed, 120 insertions(+), 199 deletions(-)

A .gitmodules
A Dockerfile
M README.md
A fxg
M kethel/main.exs
A nginx.conf
M pages/colophon.fxg
D pages/colophon.html
M pages/index.fxg
D pages/index.html
M pages/projects.fxg
D pages/projects.html
D pastes/main.rs
A .gitmodules => .gitmodules +3 -0
@@ 0,0 1,3 @@
[submodule "fxg"]
	path = fxg
	url = https://codeberg.org/m1ka/fxg.git

A Dockerfile => Dockerfile +39 -0
@@ 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

M README.md => README.md +7 -0
@@ 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'

A fxg => fxg +1 -0
@@ 0,0 1,1 @@
Subproject commit 61eb93988888de008c12e2fee91d079a91c69b7f

M kethel/main.exs => kethel/main.exs +29 -21
@@ 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 = "</channel></rss>"
  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")

A nginx.conf => nginx.conf +29 -0
@@ 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

M pages/colophon.fxg => pages/colophon.fxg +2 -2
@@ 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.


D pages/colophon.html => pages/colophon.html +0 -52
@@ 1,52 0,0 @@
<!DOCTYPE html>
<html lang="en-GB">

<head>

    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles/base.css">
<script src="/scripts/ldbuilddata.js" defer></script>

    <script src="/static/highlight.min.js"></script>
<script defer>hljs.highlightAll();</script>
<link rel="stylesheet" href="/static/arta.min.css">

    <title>home - m1kadev</title>
</head>

<body>
    <div id="content">
        <main>
            <h1>colophon</h1> <h2>about</h2> you're looking at a <a href="https://en.wiktionary.org/wiki/beautiful#English">beautiful</a> site, with <a href="https://caddyserver.com/">caddy</a> as its backend. all source pages are written in my own markup language, <a href="https://github.com/m1kadev/fxg">fxg</a>. site generation is done by a homebrewn <a href="https://github.com/m1kadev/www.m1kadev.nl/blob/main/build.exs">elixir script</a>. all code (including <a href="https://github.com/m1kadev/fxg">fxg</a>) is licenced under the MIT licence. 
            <hr>
            <footer>
    <div id="metadata">
        <p>Deployed from commit <code><span class="from-commit-short"></span></code>, on <span class="build-date"></span> </p>
    </div>
    <div id="lynx">
    <a href="https://github.com/m1kadev">
        <img src="/static/github-mark-white.svg" width="32" height="32" alt="GitHub logo">
    </a>
    </div>
</footer>
        </main>
    </div>

    <div id="mark">
    <h3>.nl</h3>
    <h1>m1kadev</h1>
    <nav>
        <hr>
        <a href="/">home</a>
        <a href="/projects.html">projects</a>
        <a href="/thoughts/">thoughts</a>
        <a href="/pastes/">pastes</a>
        <hr>
        <a href="/colophon.html">colophon</a>
    </nav>
</div>

</body>

</html>
\ No newline at end of file

M pages/index.fxg => pages/index.fxg +6 -12
@@ 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

<rust>
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

D pages/index.html => pages/index.html +0 -53
@@ 1,53 0,0 @@
<!DOCTYPE html>
<html lang="en-GB">

<head>

    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles/base.css">
<script src="/scripts/ldbuilddata.js" defer></script>

    <script src="/static/highlight.min.js"></script>
<script defer>hljs.highlightAll();</script>
<link rel="stylesheet" href="/static/arta.min.css">

    <title>home - m1kadev</title>
</head>

<body>
    <div id="content">
        <main>
            <h1>haii :3 i'm mika</h1> haiii!!! i'm mika (also <em>m1ka</em>, <em>m1kadev</em>). i'm a (mostly backend) developer from <a href="https://en.wikipedia.org/wiki/Nederland">The Netherlands</a>. i'm also a big fan of making drinks &amp; cooking. <br/><h3>about me</h3> i do VWO (dutch A-levels) phyiscs in the greater rotterdam area. i've been working on <a href="https://www.github.com/m1kadev/fxg">fxg</a>, a markup language written in <a href="https://rust-lang.org/">Rust</a>. also, i've been playing around with functional programming (mostly in <a href="https://elixir-lang.org">Elixir</a>). <br/>Together with 3 other friends, we run <a href="https://dupunkto.org/">{du}punkto</a> <br/><h3>contact</h3>feel free to reach out to me! you can reach me at m1kadev on <a href="https://discord.com/">discord</a>, or on my email address at <br/><pre><code class="language-rust">format!("{2}@{0}.{1}", "dupunkto", "org", "mika")
</code></pre><small>this code is to filter out all non-<code>format!</code> users</small> 
            <hr>
            <footer>
    <div id="metadata">
        <p>Deployed from commit <code><span class="from-commit-short"></span></code>, on <span class="build-date"></span> </p>
    </div>
    <div id="lynx">
    <a href="https://github.com/m1kadev">
        <img src="/static/github-mark-white.svg" width="32" height="32" alt="GitHub logo">
    </a>
    </div>
</footer>
        </main>
    </div>

    <div id="mark">
    <h3>.nl</h3>
    <h1>m1kadev</h1>
    <nav>
        <hr>
        <a href="/">home</a>
        <a href="/projects.html">projects</a>
        <a href="/thoughts/">thoughts</a>
        <a href="/pastes/">pastes</a>
        <hr>
        <a href="/colophon.html">colophon</a>
    </nav>
</div>

</body>

</html>
\ No newline at end of file

M pages/projects.fxg => pages/projects.fxg +4 -4
@@ 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.

D pages/projects.html => pages/projects.html +0 -52
@@ 1,52 0,0 @@
<!DOCTYPE html>
<html lang="en-GB">

<head>

    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles/base.css">
<script src="/scripts/ldbuilddata.js" defer></script>

    <script src="/static/highlight.min.js"></script>
<script defer>hljs.highlightAll();</script>
<link rel="stylesheet" href="/static/arta.min.css">

    <title>home - m1kadev</title>
</head>

<body>
    <div id="content">
        <main>
            <h1>projects</h1> <h3>fxg</h3> <a href="https://github.com/m1kadev/fxg">fxg</a> is my own markup language, written in <a href="https://rust-lang.org/">Rust</a>. it aims to maximise readability in text form, and tries to only have one way to write markup (unlike Markdown). you can view <a href="https://github.com/m1kadev/www.m1kadev.nl/blob/main/src/projects.fxg">the source</a> of this page, if you'd like to see for yourself. <br/><h3>m1kadev.nl</h3>the site you're on right now! the <a href="https://github.com/m1kadev/www.m1kadev.nl/blob/main/build.exs">generator</a> for this site is written in elixir. all code for the generator (besides <a href="https://hexdocs.pm/tzdata/readme.html">Tzdata</a>, for the build timestamp) is written by me. 
            <hr>
            <footer>
    <div id="metadata">
        <p>Deployed from commit <code><span class="from-commit-short"></span></code>, on <span class="build-date"></span> </p>
    </div>
    <div id="lynx">
    <a href="https://github.com/m1kadev">
        <img src="/static/github-mark-white.svg" width="32" height="32" alt="GitHub logo">
    </a>
    </div>
</footer>
        </main>
    </div>

    <div id="mark">
    <h3>.nl</h3>
    <h1>m1kadev</h1>
    <nav>
        <hr>
        <a href="/">home</a>
        <a href="/projects.html">projects</a>
        <a href="/thoughts/">thoughts</a>
        <a href="/pastes/">pastes</a>
        <hr>
        <a href="/colophon.html">colophon</a>
    </nav>
</div>

</body>

</html>
\ No newline at end of file

D pastes/main.rs => pastes/main.rs +0 -3
@@ 1,3 0,0 @@
fn main() {
    println!("Hello, world!");
}