Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build/
dist/
storybook-static/
docs-static/
blog-static/
coverage/

# Development files
Expand Down Expand Up @@ -137,4 +138,7 @@ package-lock.json
DEVELOPMENT.md
DEPLOYMENT.md
SECURITY.md
CLAUDE.md
CLAUDE.md
blog/node_modules/
blog/dist/
blog/.astro/
97 changes: 97 additions & 0 deletions .github/workflows/blog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Blog builder

# The blog is built in the cluster from pushed articles (blog/scripts/publish.ts). This
# workflow tests the builder and publishes its image, ghcr.io/<repo>-blog. It runs when the
# blog or the portfolio source it imports (tokens, components, site links) changes.
on:
push:
branches: [master]
paths:
- blog/**
- src/**
- .github/workflows/blog.yml
pull_request:
paths:
- blog/**
- src/**
- .github/workflows/blog.yml
workflow_dispatch:

permissions:
contents: read

jobs:
test:
name: Test the blog builder
runs-on: ubuntu-latest
defaults:
run:
working-directory: blog
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
cache-dependency-path: blog/yarn.lock

- name: Install
run: yarn install --frozen-lockfile

- name: Publish script tests
run: yarn test

- name: Type check
run: yarn typecheck
env:
ASTRO_TELEMETRY_DISABLED: 1

- name: Build the sample articles
run: yarn build:fixtures
env:
ASTRO_TELEMETRY_DISABLED: 1
NODE_ENV: production

image:
name: Publish the builder image
needs: test
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}-blog
tags: |
type=sha,format=short
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=Blog builder for derekmackley.com/blog
org.opencontainers.image.description=Builds the blog from pushed articles and switches the live site atomically. Never reads the vault.

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: blog/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: BUILD_ID=${{ github.sha }}
platforms: linux/amd64
cache-from: type=gha,scope=blog
cache-to: type=gha,mode=max,scope=blog
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules/
# production
/build
/docs-static
/blog-static
/logs

# misc
Expand Down Expand Up @@ -64,4 +65,6 @@ dist/
**/vendor
**/.bundle
**/.jekyll-cache
**/_site
**/_site/blog/node_modules
/blog/dist
/blog/.astro
40 changes: 40 additions & 0 deletions blog/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Blog builder: builds derekmackley.com/blog from pushed articles and switches the live
# site over atomically (scripts/publish.ts). Runs as a CronJob with the blog-content
# volume mounted at /content: it reads /content/articles and writes /content/site.
# It never sees the Obsidian vault.
#
# Build context is the repository root (the blog imports the portfolio's design tokens
# and React components from ../src):
# docker build -f blog/Dockerfile -t developer-portfolio-blog .

# syntax=docker/dockerfile:1
FROM node:22-alpine

ENV NODE_ENV=production \
ASTRO_TELEMETRY_DISABLED=1 \
ARTICLES_DIR=/content/articles \
SITE_DIR=/content/site

WORKDIR /app/blog

# Dependencies first, for layer caching. Dev tools (astro check, typescript) are not needed to build.
COPY blog/package.json blog/yarn.lock ./
RUN yarn install --frozen-lockfile --production --non-interactive \
&& yarn cache clean

# The shared portfolio source the blog imports (tokens, props-only components, site links)
COPY src /app/src
COPY blog/ /app/blog/

# Prove the image can build before it is published (the sample articles only)
RUN ARTICLES_DIR=/app/blog/fixtures/articles SITE_DIR=/tmp/selftest node scripts/publish.ts \
&& test -f /tmp/selftest/current/sample-article-format/index.html \
&& rm -rf /tmp/selftest /tmp/blog-*

# BUILD_ID makes a new image rebuild the site even when the articles did not change
ARG BUILD_ID=dev
ENV BUILD_ID=${BUILD_ID}

# Same uid/gid as the vault jobs and the volume's VolSync mover
USER 1000:1000
ENTRYPOINT ["node", "scripts/publish.ts"]
44 changes: 44 additions & 0 deletions blog/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @ts-check
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import rehypeCallouts from 'rehype-callouts';
import { unified } from '@astrojs/markdown-remark';

// The portfolio's source, shared read-only: design tokens and props-only React molecules
const portfolioSrc = fileURLToPath(new URL('../src', import.meta.url));

export default defineConfig({
site: 'https://derekmackley.com',
// Served by the portfolio's Express server from the blog-content volume
base: '/blog',
trailingSlash: 'ignore',
build: { format: 'directory' },
outDir: process.env.BLOG_OUT_DIR ?? './dist',
// The publisher's root filesystem is read-only; keep caches in /tmp there
cacheDir: process.env.BLOG_CACHE_DIR ?? './node_modules/.astro',
integrations: [react(), sitemap()],
markdown: {
processor: unified({
// Raw HTML in an article is not rendered; articles are Markdown only
remarkRehype: { allowDangerousHtml: false },
rehypePlugins: [[rehypeCallouts, { theme: 'github' }]],
}),
shikiConfig: { theme: 'github-dark-dimmed', wrap: true },
},
vite: {
resolve: {
alias: {
'@': portfolioSrc,
'@molecules': `${portfolioSrc}/components/molecules`,
'@atoms': `${portfolioSrc}/components/atoms`,
'@utils': `${portfolioSrc}/utils`,
'@tokens': `${portfolioSrc}/assets/css/design-system`,
},
// Components under ../src must use this package's React, not a second copy
dedupe: ['react', 'react-dom', 'framer-motion'],
},
server: { fs: { allow: ['..'] } },
},
});
7 changes: 7 additions & 0 deletions blog/fixtures/articles/sample-article-format/format.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions blog/fixtures/articles/sample-article-format/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "Sample article: the format the push process writes"
description: "Development fixture showing every element an article can use. Never published: the real articles come from the push process."
published: 2026-11-21
topics: [fixtures, format]
---

This is a **fixture** for local development and the build tests. Real articles arrive on the
`blog-content` volume from the push process, one folder per post.

## Headings and text

Plain Markdown: *emphasis*, **strong**, `inline code`, and [a link to the other sample](/blog/second-sample-post/).

> A plain blockquote for a pull quote.

> [!NOTE]
> Callouts use the GitHub form. `[!TIP]`, `[!WARNING]` and `[!IMPORTANT]` get their own colour.

> [!WARNING]
> Raw HTML is dropped: the <b>tags</b> are removed and their text stays.

## Images

Images sit next to `index.md` and are referenced relatively:

![The article format as a diagram](./format.svg)

## Code and tables

```yaml
# blog-content/articles/<slug>/index.md
title: "Waiting Is Not Failing"
published: 2026-11-21
topics: [gitops, flux]
```

| Field | Required | Notes |
|---|---|---|
| title | yes | up to 120 characters |
| description | yes | used in the list, RSS and search results |
| published | yes | YYYY-MM-DD |
| topics | no | lowercase words joined by hyphens |
9 changes: 9 additions & 0 deletions blog/fixtures/articles/second-sample-post/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Second sample post"
description: "Development fixture for the list, topics and older/newer navigation."
published: 2026-11-20
updated: 2026-11-21
topics: [fixtures]
---

A short second fixture so the index, topic pages and older/newer links have something to show.
36 changes: 36 additions & 0 deletions blog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "developer-portfolio-blog",
"private": true,
"type": "module",
"description": "derekmackley.com/blog: Astro site built from pushed articles, styled with the portfolio's design tokens. Never reads the vault.",
"engines": {
"node": ">=22.23.4"
},
"scripts": {
"dev": "ARTICLES_DIR=fixtures/articles astro dev --port 4322",
"build": "astro build",
"build:fixtures": "ARTICLES_DIR=fixtures/articles astro build",
"preview": "astro preview --port 4322",
"publish:site": "node scripts/publish.ts",
"typecheck": "astro check",
"test": "node --test 'scripts/**/*.test.ts'"
},
"dependencies": {
"@astrojs/markdown-remark": "7.3.10",
"@astrojs/react": "7.1.9",
"@astrojs/rss": "4.0.19",
"@astrojs/sitemap": "3.7.6",
"astro": "7.4.13",
"framer-motion": "14.14.0",
"react": "19.3.1",
"react-dom": "19.3.1",
"rehype-callouts": "2.2.0"
},
"devDependencies": {
"@astrojs/check": "^0.9.12",
"@types/node": "^26.6.6",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"typescript": "6.0.3"
}
}
Loading
Loading