buro9 / microcosm

Front end for Microcosm, a Go web server that serves the static files, templates and performs API calls.
GNU Affero General Public License v3.0
11 stars 3 forks source link

Makefile: "run" and "refresh" targets build inside docker container #56

Closed yemble closed 7 years ago

yemble commented 7 years ago

Ensures the executable is built for the same cpu architecture as the running container when using a mounted volume via docker-compose.

buro9 commented 7 years ago

Question: Are you going to run it locally at all? Or just in the container?

It's possible to have Go just compile it for a different architecture whilst on your Mac.

From the API project:

build: export GOOS=linux
build: export GOARCH=amd64
build: clean
    @go build cmd/microcosm/microcosm.go

It's better to have it build on the host as you'll retain Go's partial compilation which dramatically speeds up the time to build.

Might still be worth having a different build step so you retain the option of running locally, but at least if it's built on the host you get faster builds.

yemble commented 7 years ago

Hadn't really thought that far through - I just like the run/refresh workflow and this was a quick fix to stop the container from crashing. Happy to keep this in my fork. If the speed gets on my nerves, I'll do something about it, probably cross compile as you say.