From 12ce629b318cbd05f353a98a8e8b83b5cafa8099 Mon Sep 17 00:00:00 2001 From: jbergner Date: Sat, 10 May 2025 19:13:29 +0200 Subject: [PATCH] =?UTF-8?q?Anpassung=20f=C3=BCr=20dynamische=20Content-Git?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/release.yml | 18 +++++++++++++++++- Dockerfile | 3 +++ cmd/blog/main.go | 13 +++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 20912ac..7f76155 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -43,9 +43,25 @@ jobs: with: context: . file: ./Dockerfile + build-args: | + CONTENT_REPO=https://git.send.nrw/b1tsblog/blogcontent.git + CONTENT_REF=main platforms: | linux/amd64 push: true tags: | # replace it with your local IP and tags ${{ vars.DOCKER_REGISTRY }}/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} - ${{ vars.DOCKER_REGISTRY }}/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }} \ No newline at end of file + ${{ vars.DOCKER_REGISTRY }}/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }} + - name: Build and push StarCitizen + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + build-args: | + CONTENT_REPO=https://git.send.nrw/b1tsblog/sccontent.git + CONTENT_REF=main + platforms: | + linux/amd64 + push: true + tags: | # replace it with your local IP and tags + ${{ vars.DOCKER_REGISTRY }}/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:sc-${{ env.DOCKER_LATEST }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ab44add..a46e6f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,7 @@ 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/ +RUN cp -r /src/templates/* /out/templates/ ############################ @@ -52,10 +53,12 @@ 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 EXPOSE 8080 CMD ["blog"] diff --git a/cmd/blog/main.go b/cmd/blog/main.go index 6675e14..fe652ed 100644 --- a/cmd/blog/main.go +++ b/cmd/blog/main.go @@ -57,6 +57,11 @@ func main() { staticDir = "/pages" } + templatesDir := os.Getenv("BLOG_TEMPLATES_DIR") + if templatesDir == "" { + templatesDir = "/templates" + } + funcs := template.FuncMap{ "now": time.Now, // jetzt‑Zeit bereitstellen } @@ -64,19 +69,19 @@ func main() { // Basislayout zuerst parsen layout := template.Must( template.New("base").Funcs(funcs). - ParseFiles("/app/internal/web/templates/base.html"), + ParseFiles(templatesDir + "/base.html"), ) // LIST‑Seite: base + list.html tplList = template.Must(layout.Clone()) - template.Must(tplList.Funcs(funcs).ParseFiles("/app/internal/web/templates/list.html")) + template.Must(tplList.Funcs(funcs).ParseFiles(templatesDir + "/list.html")) // ARTICLE‑Instanz tplArticle = template.Must(layout.Clone()) - template.Must(tplArticle.Funcs(funcs).ParseFiles("/app/internal/web/templates/article.html")) + template.Must(tplArticle.Funcs(funcs).ParseFiles(templatesDir + "/article.html")) tplPage := template.Must(layout.Clone()) - template.Must(tplPage.ParseFiles("/app/internal/web/templates/page.html")) + template.Must(tplPage.ParseFiles(templatesDir + "/page.html")) mux := http.NewServeMux()