Files
b1tsblog/Dockerfile
jbergner b83eff82a0
All checks were successful
release-tag / release-image (push) Successful in 1m58s
Testfix for loop restart #3
2025-05-04 18:39:54 +02:00

62 lines
1.8 KiB
Docker
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

############################
# 1) GoBuild
############################
FROM golang:1.23.1 AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /blog ./cmd/blog
############################
# 2) ContentClone (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)
RUN mkdir -p /out/content /out/static /out/pages
RUN find /src/articles -name '*.md' -exec cp {} /out/content/ \;
RUN cp -r /src/static/* /out/static/
RUN cp -r /src/pages/* /out/pages/
############################
# 3) RuntimeImage
############################
FROM debian:bookworm-slim
# (optional) MySQLClient für später
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# ─── Binärdatei ─────
COPY --from=build /blog /usr/local/bin/blog
# ─── Content + Assets ───
RUN mkdir -p /content /static /pages /app
COPY . /app
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"]