GoTemplate not found with Docker deployment
Pumkko opened this issue · comments
I have a flamingo app https://github.com/Pumkko/learn-flamingo-solid which I use to provide a backend API under /api and serve static files compiled from a SolidJS app under /
When i try to run the app with Docker the API is accessible however localhost:3322 always fail :
open templates: no such file or directory
Here are some code snippet which work fine when i just build the app manually and run it manually
config/config.yml
flamingo.debug.mode: false
core:
zap:
loglevel: Debug
json: true
gotemplates:
engine:
templates:
basepath: "frontend/dist", # template directory
src/solidFront/module.go
func (r *routes) Routes(registry *web.RouterRegistry) {
registry.MustRoute("/", "index")
registry.HandleGet("index", r.solidController.Index)
registry.MustRoute("/*name", `flamingo.static.file(name, dir?="frontend/dist")`)
}
Dockerfile
# Example Dockerfile for Flamingo/Go based Projects
FROM node:20-alpine as nodebuild
WORKDIR /usr/src/app
COPY ./frontend /usr/src/app
RUN npm ci && npm run build
# Builder
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache ca-certificates tzdata git && update-ca-certificates
COPY . /app
RUN cd /app && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o klanikApp .
# Final image
FROM scratch
# add timezone data and ssl root certificates
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# add artifacts
ADD config/config.yml /usr/src/config/config.yml
# add binary
COPY --from=builder /app/klanikApp /usr/src/klanikApp
COPY --from=nodebuild /usr/src/app/dist /usr/src/frontend/dist
ENTRYPOINT ["/usr/src/klanikApp"]
CMD ["serve", "-a", ":8080"]
I then just built it with docker build -t flamingo:latest .
and run it with docker run -d -p 3322:3322 flamingo:latest
The compiled app does not seem to be able to find the configuration file since any change in that file are not reflected in the app or in the generated logs
PS : Here's a screenshot of the directory within the docker container