http://blog.scottlogic.com/cprice/assets/hot-reloading.gif

Auto Rebuilding Go Programs — With Docker, Glide & Fresh

Introduction

Setting Up Fresh & Glide

It works great and certainly does what we need it to.

In essence it’s a beautiful wrapper around “go get”, with a configuration file, version locking and caching. Why wouldn’t you use it?

ignored: assets, tmp, vendor

Setting Up Docker

# create image from the official Go image
FROM golang:alpine
RUN apk add --update tzdata \
bash wget curl git;
# Create binary directory, install glide and fresh
RUN mkdir -p $$GOPATH/bin && \
curl https://glide.sh/get | sh && \
go get github.com/pilu/fresh
# define work directory
ADD . /go/src/project_folder
WORKDIR /go/src/project_folder
# serve the app
CMD glide update && fresh -c runner.conf main.go
docker run -it --volume=$(PWD):/go/src/project_folder --name=my_project_name image_name
docker run -it --volume=$(PWD):/go/src/project_folder --name=my_project_name --network=my_app image_name

Multi-pronged web developer with a passion for cutting edge tooling! https://craigchilds.dev