<p>I have the following directory structure:</p>
<pre><code>templates/
  a.tmpl
services/
  service.go
main.go
</code></pre>
<p>Now inside the <code>service.go</code> file i am calling the below function:</p>
<pre><code>dir, err := filepath.Abs(filepath.Dir(&quot;./templates/&quot;))
    if err != nil {
        return nil, err
    }


    baseFile := filepath.Join(dir, &quot;a.tmpl&quot;)

tmpl, err := template.New(&quot;base&quot;).ParseFiles(baseFile)
</code></pre>
<p>now the above function is parsing my <code>a.tmpl</code> file as expected.</p>
<p>but once this service is up on docker and kubernetes, i am no longer able to open the file since the file does not exists</p>
<p>why is that?</p>
<p>UPDATE:</p>
<pre><code>FROM golang:1.16-buster AS builder
# Copy the code from the host and compile it
WORKDIR $GOPATH/src/github.com/me/report
COPY . ./
# pack templates to binary
RUN CGO_ENABLED=0 GOOS=linux go build -mod vendor -ldflags &quot;-X github.com/me/report/cmd.version=$(cat .VERSION)&quot; -o /app .

FROM xyz.amazonaws.com/common/platform/base:latest as prod
COPY --from=builder /app ./
ADD ./migrations /migrations
ENTRYPOINT [&quot;/app&quot;]
</code></pre>

HexaCrop
<p>Just copy the templates folder from the builder, like:</p>
<pre><code>COPY --from=builder /app ./
ADD ./migrations /migrations
COPY --from=builder ./templates /templates

</code></pre>
<p>or add the folder like:</p>
<pre><code>COPY --from=builder /app ./
ADD ./migrations /migrations
ADD ./templates /templates

</code></pre>
