Skip to content

Commit

Permalink
Add books I read on vacation (#123)
Browse files Browse the repository at this point in the history
* Add books I read on vacation

* Please build

* It builds locally, will it build on GitHub?

* jpeg -> jpg

* Tweak

* wtf

* fff

* Will it build

* Fuck

* Add post about sucky Dash Carts

* Ditch pointless remark-kroki fork

* Add additional dig about size of sensor package

* Brave new container world

* Add key to cache action

* Pull builder, fix build command

* Pull Kroki separately

* Pull Kroki too, not just its deps

* Log in to ghcr.io
  • Loading branch information
jordemort authored May 3, 2024
1 parent 9cdd063 commit 41630cb
Show file tree
Hide file tree
Showing 15 changed files with 4,588 additions and 2,046 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/astro-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build blog

on:
pull_request:
push:
branches:
- "main"

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-22.04
env:
TZ: America/Chicago
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
key: ${{ runner.os }}-node-modules
path: node_modules

- name: Pull Kroki containers
run: docker compose pull kroki blockdiag mermaid bpmn excalidraw

- name: Try to pull builder
run: docker compose pull astro || true

- name: Build and maybe push builder
uses: docker/build-push-action@v5
with:
cache-to: type=inline
pull: true
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/jordemort/jordemort-blog-builder:latest
target: astro

- name: Build site
run: docker compose run --rm astro npm run build

- name: Build and push dependencies
uses: docker/build-push-action@v5
if: ${{ github.event_name == 'push' }}
with:
push: true
tags: ghcr.io/jordemort/jordemort-blog-dependencies:latest
target: dependencies

- name: Build and push site
uses: docker/build-push-action@v5
if: ${{ github.event_name == 'push' }}
with:
push: true
tags: ghcr.io/jordemort/jordemort-blog:latest
target: dependencies
54 changes: 0 additions & 54 deletions .github/workflows/deploy.yml

This file was deleted.

32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM node:18-bookworm AS astro

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
build-essential \
dumb-init \
gosu \
libpixman-1-dev \
libcairo2-dev \
libpango1.0-dev \
pkg-config

COPY astro-entrypoint.sh /usr/local/bin/astro-entrypoint.sh

ENTRYPOINT [ "/usr/bin/dumb-init", "/usr/local/bin/astro-entrypoint.sh" ]

########################################################################

FROM scratch AS dependencies

COPY package.json /package.json
COPY package-lock.json /package-lock.json
COPY node_modules/ /node_modules/

########################################################################

FROM joseluisq/static-web-server:2 AS site

COPY dist/ /var/www/

ENV SERVER_ROOT=/var/www
25 changes: 25 additions & 0 deletions astro-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -euo pipefail

my_uid=$(id -u)
want_uid=$(stat -c '%u' .)

if [ "$my_uid" != "$want_uid" ] ; then
existing_user=$(getent passwd "$want_uid" | cut -d: -f1 || true)
if [ -n "$existing_user" ] ; then
userdel -r "$existing_user"
fi

want_gid=$(stat -c '%g' .)
existing_group=$(getent group "$want_gid" || true)
if [ -z "$existing_group" ] ; then
groupadd -g "$want_gid" astro
fi

useradd -m -u "$want_uid" -g "$want_gid" astro
exec gosu astro "$0" "$@"
fi

npm install
exec "$@"
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default defineConfig({
remarkMath,
remarkPluginOembed,
[remarkKroki, {
server: "http://127.0.0.1:62580",
server: "http://kroki:62580",
alias: ["graphviz", "mermaid", "plantuml", "svgbob"],
inline: true
}]
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
services:
kroki:
image: yuzutech/kroki:latest
depends_on:
- blockdiag
- mermaid
- bpmn
- excalidraw
environment:
- KROKI_BLOCKDIAG_HOST=blockdiag
- KROKI_MERMAID_HOST=mermaid
- KROKI_BPMN_HOST=bpmn
- KROKI_EXCALIDRAW_HOST=excalidraw

blockdiag:
image: yuzutech/kroki-blockdiag:latest
expose:
- "8001"

mermaid:
image: yuzutech/kroki-mermaid:latest
expose:
- "8002"

bpmn:
image: yuzutech/kroki-bpmn:latest
expose:
- "8003"

excalidraw:
image: yuzutech/kroki-excalidraw:latest
expose:
- "8004"

astro:
image: ghcr.io/jordemort/jordemort-blog-builder:latest
build:
context: .
target: astro
depends_on:
- kroki
volumes:
- .:/usr/src/jordemort.dev
working_dir: /usr/src/jordemort.dev
Loading

0 comments on commit 41630cb

Please sign in to comment.