gin-air-docker-boilerplate

command module
v0.0.0-...-1dd0f12 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 7 Imported by: 0

README

Project boilerplate: Go + Gin + Docker + Air

A containerised Gin app boilerplate, with a containerised development environment using Air and Docker Compose.

Component Choice
Language Go
Framework Gin
Hot Reloading Air
Containerisation Docker

Development

Install the dependancies:

This project uses Go mod, the official module manager, to handle Go modules in a portable way without having to worry about GOPATH.

go mod download
go mod verify

Define environment variables for your development environment:

These are passed to the Docker container via docker-compose.yaml in development. When running in production, the environment variables must be passed to the container when it is run.

cp .env.example .env
vim .env

Run locally:

This builds the Docker image and runs it automatically with the config defined in docker-compose.yaml. This saves you having to build the docker image and then run a manual docker run command with all the flags (for environment variables, ports, etc).

docker compose up

Production

Note: Environment variables are never baked into the image, or they wouldn't be environment variables. The production environment will start a Docker container based on this image, but it will have to pass the environment variables to the container when it runs it.

# Build Docker image for production:
docker build -t gin-air-docker-boilerplate -f Dockerfile.production .

# Example manually running a container with environment variables and ports defined:
docker run -p 8080:8080 -e SUPER_SECRET_KEY=abc123 gin-air-docker-boilerplate

Stargazers over time

Stargazers over time

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
src
di

Jump to

Keyboard shortcuts

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