Missing files in Golang deploy to fly.io

I have made a go rest API server using the Fiber framework. I am using the default html template engine provided by Fiber to render .html files placed within a directory called internal/ui/templates.

My project structure is as follows:

├── bin
│   └── gwpl-api
├── cmd
│   └── main.go
├── go.mod
├── go.sum
├── internal
│   ├── app.go
│   ├── database
│   ├── plugins
│   │   ├── auth
│   │   │   └── auth.go
│   │   ├── customers
│   │   │   └── customers.go
│   │   └── plugins.go
│   └── ui
│       └── templates
│           └── index.html
├── Makefile
└── README.md

This is the code that executes the server and renders the template -

import (


// App defines the main backend application.
type App struct {
	port   string
	server *fiber.App
	log    *zap.Logger

// NewApp creates a new `App` struct.
func NewApp(port string) App {
	return App{
		port: port,
		server: fiber.New(fiber.Config{
			Views: html.New("internal/ui/templates", ".html"),
		log: zap.NewExample(),

// ServerHTTP Starts the fiber HTTP Server defined within `App`.
func (app *App) ServeHTTP() {
	// Render index template
	app.server.Get("/", func(c *fiber.Ctx) error {
		data := map[string]string{
			"Region": os.Getenv("FLY_REGION"),
		return c.Render("index", data)

	app.log.Info("Starting Fiber server.", zap.String("port", app.port))
	app.server.Listen(":" + app.port)

These functions are called in the cmd/main.go file, within the main() function.

When I execute the binary built with the go build command, it works perfectly on my local machine, regardless of where I move the binary, but as soon as I deploy the app to fly.io, I get a [Warn] failed to load views: lstat internal/ui/templates: no such file or directory. when checking the Monitoring section on the application details page.

How do I remedy the situation?

Your VM may not have the template files. Did you ADD/COPY internal/ui/templates in your Dockerfile?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.