go-template-web

command module
v0.0.0-...-74d4a7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2024 License: CC0-1.0 Imports: 4 Imported by: 0

README

go-template-web

This is a quick and simple example of a Go application configured with a completely containerized dev environment. Features include Live Reloading, Remote Debugging, and a multi-layer containerized production build definition.

Built With
  • Golang

Instructions

Development

The included docker-compose configuration is set up to initialize a fully-featured dev environment utilizing Air for live-reloading and Delve for remote debugging.

> docker compose up -d

To facilitate debugging in VSCode, a launch configuration has been included that you can use to attach the VSCode debugger to the running dev environment.

Release

To generate a release image, simply build the docker file. This utilizes a dedicated build stage along with the scratch Docker image to ensure the final image contains only the necessary resources and nothing else.

> docker build . -t go-template-web
> docker run -e HOST= -p 8080:8080 go-template-web

Example Application

The application provided with this example is a lightweight web service hosting static files out of the ./public directory and templated responses out of the ./templates directory. It is also set up to utilize environment variables for application configuration. These can either be set directly in the execution environment, included as part of a docker-compose.yaml definition, or provided in a .env file in the execution directory. The .env file will always be overridden by other methods so is particularly useful for development. The service will also fall back to a default value if one is not otherwise provided.

Variable Description Default
HOST The host network that requests should be serviced from. localhost
PORT The port that hosts the configuration UI and aggregated feeds. 80
Example .env File
HOST=
PORT=8080

License

This example code is provided to the public domain via the CC0 1.0 Universal License. See LICENSE.md for more information.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址