All checks were successful
release-tag / release-image (push) Successful in 2m14s
71 lines
2.0 KiB
Docker
71 lines
2.0 KiB
Docker
############################
|
||
# 1) Go‑Build
|
||
############################
|
||
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) 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 ────────────────
|
||
# • 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 /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/
|
||
|
||
|
||
############################
|
||
# 3) Runtime‑Image
|
||
############################
|
||
FROM debian:bookworm-slim
|
||
|
||
# (optional) MySQL‑Client für später
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
ca-certificates git \
|
||
&& 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 /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
|
||
|
||
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 GIT_ENABLE=false
|
||
ENV GIT_REPO=null
|
||
ENV GIT_BRANCH=main
|
||
ENV GIT_DIR=/git-temp
|
||
ENV GIT_INTERVAL=10
|
||
|
||
EXPOSE 8080
|
||
CMD ["blog"]
|