Update
All checks were successful
release-tag / release-image (push) Successful in 2m46s

This commit is contained in:
2026-05-18 13:16:52 +02:00
parent 1292b1649d
commit 39e6bea5b6
3 changed files with 93 additions and 68 deletions

View File

@@ -1,65 +1,86 @@
############################
# 1) GoBuild
# 1) Go-Build
############################
FROM golang:1.26 AS build
FROM golang:1.26-alpine AS build
WORKDIR /app
COPY go.mod go.sum ./
# git wird für private/selbst gehostete Module benötigt.
RUN apk add --no-cache git ca-certificates
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /blog .
# modernc.org/sqlite läuft ohne CGO.
# Dadurch brauchen wir keine gcc/libsqlite3-dev Pakete und bekommen ein schlankes Binary.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o /blog .
############################
# 2) ContentClone (Stage)
# 2) Content-Clone Stage
############################
FROM alpine/git AS content
# Parameterisierbar beim docker build --build-arg …
ARG CONTENT_REPO=https://git.send.nrw/b1tsblog/blogcontent.git
ARG CONTENT_REF=main
RUN git clone --depth 1 --branch ${CONTENT_REF} ${CONTENT_REPO} /src
# ─── Repack: bring alles in eine saubere Struktur ────────────────
# • MarkdownPosts: /articles/*.md → /out/content
# • Bilder + CSS + JS: /static/**/* → /out/static
# statische Seiten: /pages/* → /out/pages
# (PfadAnpassung hier nach DEINEM RepositoryLayout)
# Zielstruktur:
# /out/content Artikel: .md und .html
# /out/static CSS, Bilder, JS
# /out/pages statische Seiten: .md und .html
# /out/templates Templates
RUN mkdir -p /out/content /out/static /out/pages /out/templates
RUN mkdir -p /out/content /out/static /out/pages /out/templates/
RUN find /src/articles -name '*.md' -exec cp {} /out/content/ \;
RUN cp -r /src/static/* /out/static/
RUN cp -r /src/pages/* /out/pages/
RUN cp -r /src/templates/* /out/templates/
RUN if [ -d /src/articles ]; then \
find /src/articles \( -name '*.md' -o -name '*.html' \) -exec cp {} /out/content/ \; ; \
fi
RUN if [ -d /src/static ]; then \
cp -r /src/static/. /out/static/ ; \
fi
RUN if [ -d /src/pages ]; then \
find /src/pages \( -name '*.md' -o -name '*.html' \) -exec cp {} /out/pages/ \; ; \
fi
RUN if [ -d /src/templates ]; then \
cp -r /src/templates/. /out/templates/ ; \
fi
############################
# 3) RuntimeImage
# 3) Runtime-Image
############################
FROM debian:bookworm-slim
FROM alpine:3.21
# (optional) MySQLClient für später
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache ca-certificates git tzdata
RUN mkdir -p \
/content \
/static \
/pages \
/templates \
/data \
/git-temp
# ─── Binärdatei ─────
COPY --from=build /blog /usr/local/bin/blog
# ─── Content + Assets ───
RUN mkdir -p /content /static /pages /app /templates /ticks
COPY . /app
COPY --from=content /out/content /content
COPY --from=content /out/static /static
COPY --from=content /out/pages /pages
COPY --from=content /out/templates /templates
COPY --from=content /out/static /static
COPY --from=content /out/pages /pages
COPY --from=content /out/templates /templates
ENV BLOG_CONTENT_DIR=/content
ENV BLOG_STATIC_DIR=/static
ENV BLOG_PAGES_DIR=/pages
ENV BLOG_TEMPLATES_DIR=/templates
ENV BLOG_TICKS_DIR=/ticks
ENV BLOG_DATA_DIR=/data
ENV BLOG_TRUSTED_HTML=true
ENV GIT_ENABLE=false
ENV GIT_REPO=null
ENV GIT_BRANCH=main
@@ -67,4 +88,5 @@ ENV GIT_DIR=/git-temp
ENV GIT_INTERVAL=10
EXPOSE 8080
CMD ["blog"]

27
docker-compose.yml Normal file
View File

@@ -0,0 +1,27 @@
services:
b1tsblog:
build:
context: .
dockerfile: Dockerfile
args:
CONTENT_REPO: https://git.send.nrw/b1tsblog/blogcontent.git
CONTENT_REF: main
container_name: b1tsblog
restart: unless-stopped
ports:
- "8080:8080"
environment:
BLOG_CONTENT_DIR: /content
BLOG_STATIC_DIR: /static
BLOG_PAGES_DIR: /pages
BLOG_TEMPLATES_DIR: /templates
BLOG_DATA_DIR: /data
BLOG_TRUSTED_HTML: "true"
GIT_ENABLE: "false"
GIT_REPO: "https://git.send.nrw/b1tsblog/blogcontent.git"
GIT_BRANCH: main
GIT_DIR: /git-temp
GIT_INTERVAL: "10"
volumes:
- ./data:/data

View File

@@ -1,39 +1,15 @@
{{ define "layout" }}
<!DOCTYPE html>
{{ define "layout" }}<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
{{ if .Description }}
<meta name="description" content="{{ .Description }}">
{{ end }}
<title>{{ block "title" . }}B1tsblog{{ end }}</title>
<link rel="icon" type="image/vnd.icon" href="/static/img/favicon.ico">
<link rel="stylesheet" href="/static/main.css">
</head>
<body>
<header>
<h1><a href="/" class="no-underline">B1tsblog</a></h1>
<nav class="main-nav">
<ul>
<li><a class="no-underline" href="/">Start</a></li>
<li><a class="no-underline" href="/page/welcome">Hallo</a></li>
<li><a class="no-underline" href="/page/ai">KI</a></li>
<li><a class="no-underline" href="/page/datenschutzerklaerung">Datenschutz</a></li>
<li><a class="no-underline" href="/page/impressum">Impressum</a></li>
</ul>
</nav>
</header>
<main class="wrapper">
{{ template "body" . }}
</main>
<footer class="wrapper">
© {{ now.Year }} · Jan Bergner / B1tsBlog
<hr>
Ich verzichte auf Cookies, affiliate Links, Tracking und die Einbindung von Drittanbieter-Diensten.
</footer>
</body>
</html>
{{ end }}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ .Title }}</title>
<meta name="description" content="{{ .Description }}">
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<header><a href="/">B1TS Blog</a></header>
<main>{{ template "content" . }}</main>
<footer>© {{ now.Format "2006" }}</footer>
</body>
</html>{{ end }}