Anpassung auf dynamisches GIT
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -16,19 +16,21 @@ RUN CGO_ENABLED=0 go build -o /blog ./cmd/blog
|
||||
FROM alpine/git AS content
|
||||
|
||||
# Parameterisierbar beim docker build --build-arg …
|
||||
ARG CONTENT_REPO=https://github.com/username/blog-content.git
|
||||
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 ────────────────
|
||||
# • Markdown‑Posts: /src/articles/*.md → /out/content
|
||||
# • Bilder + CSS + JS: /src/web/static/**/* → /out/static
|
||||
# • Markdown‑Posts: /articles/*.md → /out/content
|
||||
# • Bilder + CSS + JS: /static/**/* → /out/static
|
||||
# • statische Seiten: /pages/* → /out/pages
|
||||
# (Pfad‑Anpassung hier nach DEINEM Repository‑Layout)
|
||||
|
||||
RUN mkdir -p /out/content /out/static
|
||||
RUN find /src/articles -name '*.md' -exec cp {} /out/content/ \;
|
||||
RUN cp -r /src/web/static/* /out/static/
|
||||
RUN find /articles -name '*.md' -exec cp {} /out/content/ \;
|
||||
RUN cp -r /static/* /out/static/
|
||||
RUN cp -r /pages/* /out/pages/
|
||||
|
||||
|
||||
############################
|
||||
@@ -47,9 +49,11 @@ COPY --from=build /blog /usr/local/bin/blog
|
||||
# ─── Content + Assets ───
|
||||
COPY --from=content /out/content /content
|
||||
COPY --from=content /out/static /static
|
||||
COPY --from=content /out/pages /pages
|
||||
|
||||
ENV BLOG_CONTENT_DIR=/content
|
||||
ENV BLOG_STATIC_DIR=/static
|
||||
ENV BLOG_PAGES_DIR=/pages
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["blog"]
|
||||
|
@@ -41,6 +41,22 @@ var (
|
||||
|
||||
func main() {
|
||||
|
||||
// --- Verzeichnisse konfigurierbar machen -------------------------
|
||||
contentDir := os.Getenv("BLOG_CONTENT_DIR")
|
||||
if contentDir == "" {
|
||||
contentDir = "content" // Fallback für local run
|
||||
}
|
||||
|
||||
staticDir := os.Getenv("BLOG_STATIC_DIR")
|
||||
if staticDir == "" {
|
||||
staticDir = "internal/web/static"
|
||||
}
|
||||
|
||||
pagesDir := os.Getenv("BLOG_PAGES_DIR")
|
||||
if staticDir == "" {
|
||||
staticDir = "pages"
|
||||
}
|
||||
|
||||
funcs := template.FuncMap{
|
||||
"now": time.Now, // jetzt‑Zeit bereitstellen
|
||||
}
|
||||
@@ -64,14 +80,12 @@ func main() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
staticDir := "internal/web/static"
|
||||
|
||||
articles, err := article.LoadDir("content")
|
||||
articles, err := article.LoadDir(contentDir)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
staticPages, err := article.LoadStatic("pages")
|
||||
staticPages, err := article.LoadStatic(pagesDir)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user