1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-07-15 01:34:32 +02:00

Merge branch 'issue/29-hot-reload-fix' into 'master'

issue #29 fixed hot reload of html templates

See merge request geeks-accelerator/oss/saas-starter-kit!21
This commit is contained in:
Lee Brown
2020-01-18 22:23:48 +00:00
5 changed files with 34 additions and 24 deletions

View File

@ -1,3 +1,8 @@
# To manully execute build locally use:
# docker build -f cmd/web-api/Dockerfile --build-arg name=web-api .
# This uses a multi-stage docker file. You can use target to build a specific stage.
# docker build -f cmd/web-api/Dockerfile --build-arg name=web-api --target dev .
FROM golang:1.13.5-alpine3.11 AS build_base_golang
LABEL maintainer="lee@geeksinthewoods.com"
@ -60,20 +65,21 @@ COPY internal ./internal
# Copy cmd specific packages.
COPY ${code_path} ${code_path}
COPY ${code_path}/templates /templates
#COPY ${code_path}/static /static
COPY ${code_path}/templates /build/templates
#COPY ${code_path}/static /build/static
# Copy the global templates.
ADD resources/templates/shared /templates/shared
ADD configs/fresh-auto-reload.conf /runner.conf
ADD resources/templates/shared /build/templates/shared
ADD configs/fresh-auto-reload.conf /build/runner.conf
ENV TEMPLATE_DIR=/templates
ENV SHARED_TEMPLATE_DIR=/templates/shared
#ENV STATIC_DIR=/static
# These need to be relative paths for Hot reloads to work with docker-compose.
ENV TEMPLATE_DIR=./templates
ENV SHARED_TEMPLATE_DIR=../../resources/templates/shared
#ENV STATIC_DIR=./static
WORKDIR ${code_path}
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
ENTRYPOINT ["fresh", "-c", "/build/runner.conf"]
FROM dev AS builder
@ -88,9 +94,7 @@ FROM alpine:3.11
RUN apk --update --no-cache add \
tzdata ca-certificates curl openssl
COPY --from=builder /gosrv /
#COPY --from=builder /static /static
COPY --from=builder /templates /templates
COPY --from=builder /build /
ENV TEMPLATE_DIR=/templates
ENV SHARED_TEMPLATE_DIR=/templates/shared

View File

@ -1,3 +1,8 @@
# To manully execute build locally use:
# docker build -f cmd/web-app/Dockerfile --build-arg name=web-app .
# This uses a multi-stage docker file. You can use target to build a specific stage.
# docker build -f cmd/web-app/Dockerfile --build-arg name=web-app --target dev .
FROM golang:1.13.5-alpine3.11 AS build_base_golang
LABEL maintainer="lee@geeksinthewoods.com"
@ -39,20 +44,21 @@ COPY internal ./internal
# Copy cmd specific packages.
COPY ${code_path} ${code_path}
COPY ${code_path}/templates /templates
COPY ${code_path}/static /static
COPY ${code_path}/templates /build/templates
COPY ${code_path}/static /build/static
# Copy the global templates.
ADD resources/templates/shared /templates/shared
ADD configs/fresh-auto-reload.conf /runner.conf
ADD resources/templates/shared /build/templates/shared
ADD configs/fresh-auto-reload.conf /build/runner.conf
ENV TEMPLATE_DIR=/templates
ENV SHARED_TEMPLATE_DIR=/templates/shared
ENV STATIC_DIR=/static
# These need to be relative paths for Hot reloads to work with docker-compose.
ENV TEMPLATE_DIR=./templates
ENV SHARED_TEMPLATE_DIR=../../resources/templates/shared
ENV STATIC_DIR=./static
WORKDIR ${code_path}
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
ENTRYPOINT ["fresh", "-c", "/build/runner.conf"]
FROM dev AS builder
@ -63,9 +69,7 @@ FROM alpine:3.11
RUN apk --update --no-cache add \
tzdata ca-certificates curl openssl
COPY --from=builder /gosrv /
COPY --from=builder /static /static
COPY --from=builder /templates /templates
COPY --from=builder /build /
ENV TEMPLATE_DIR=/templates
ENV SHARED_TEMPLATE_DIR=/templates/shared

View File

@ -4,7 +4,6 @@
{{end}}
{{ define "content" }}
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>

View File

@ -1,5 +1,5 @@
root: .
tmp_path: ./tmp
tmp_path: /tmp
build_name: runner-build
build_log: runner-build-errors.log
valid_ext: .go, .tpl, .tmpl, .html, .gohtml

View File

@ -217,6 +217,9 @@ func NewTemplateRenderer(templateDir string, enableHotReload bool, globalViewDat
// Recursively loop through all folders/files in the template directory and group them by their
// template type. They are filename / filepath for lookup on render.
err := filepath.Walk(templateDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return errors.WithMessagef(err, "Failed to list directory %s", path)
}
dir := filepath.Base(filepath.Dir(path))
// Skip directories.