finale Anpassung
This commit is contained in:
74
Dockerfile
74
Dockerfile
@@ -1,19 +1,55 @@
|
||||
# --- Build step ---
|
||||
FROM golang:1.22 AS build
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -o /blog ./cmd/blog
|
||||
|
||||
# --- Runtime + optional MySQL client libraries ---
|
||||
FROM debian:bookworm-slim
|
||||
RUN apt-get update && apt-get install -y default-mysql-client ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=build /blog /usr/local/bin/blog
|
||||
COPY content/ /content
|
||||
COPY internal/web/static/ /static
|
||||
EXPOSE 8080
|
||||
ENV BLOG_CONTENT_DIR=/content
|
||||
ENV BLOG_STATIC_DIR=/static
|
||||
CMD ["blog"]
|
||||
|
||||
############################
|
||||
# 1) Go‑Build
|
||||
############################
|
||||
FROM golang:1.22 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://github.com/username/blog-content.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
|
||||
# (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/
|
||||
|
||||
|
||||
############################
|
||||
# 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 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# ─── Binärdatei ─────
|
||||
COPY --from=build /blog /usr/local/bin/blog
|
||||
|
||||
# ─── Content + Assets ───
|
||||
COPY --from=content /out/content /content
|
||||
COPY --from=content /out/static /static
|
||||
|
||||
ENV BLOG_CONTENT_DIR=/content
|
||||
ENV BLOG_STATIC_DIR=/static
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["blog"]
|
||||
|
Reference in New Issue
Block a user