Sorry if this is a duplicate issue. But it would be very helpful to onboard new contributors and anyone who just wants to interact with Athens with nothing but docker (no buffalo needed, not even Go is needed)
Let's have our dev set up to two tiers:
Just spin things up, I hate installing things.
docker-compose up athens-dev -- this will spin up the minimum dependencies but as well as two docker images (one for proxy and one for athens) that will already have buffalo and a module-enabled-go binary in them. So all you have to do is ping localhost:3000
I'd like to contribute and know how things work and be able to develop fast.
We already have this, just good old manual install of Go, Buffalo, and >go1.11beta3
Use case one covered in #81
@michalpristas Thanks for showing me this issue! 81 seems to be for publishing images which will probably be optimized without having buffalo or GOPATH. Does it cover building a local docker image just for development purposes (onboarding new contributors) ?
what do you mean by having a buffalo?
81 should result in a pair of docker images which you can download, deploy and play with
@michalpristas I assume 81 is about production-ready docker images. They can totally be used to play with locally. But they will probably be optimized, for example it will probably be FROM scratch and so a user cannot open a shell into the container and debug things. It might be a nicer experience to provide a local Dockerfile (never published to docker hub) that is FROM buffalo and also has everything a user needs to "hack on Athens".
You're right though, a user can totally download and play with the docker images from 81, but maybe we should give them a more powerful docker image for local development?
Either way is cool w/e me :)
i think it goes hand in hand and one precedes the other. we can start with playable image and than productize it into publishable form
@michalpristas that would be great. Last time I checked though, Docker does not let you build one file from a multi-build file. Has that changed? It would be quite awesome if we can do something like the following:
FROM golang:1.11-rc AS athens-dev
# DO ALL THE THINGS
FROM scratch
COPY --from=athens-dev athensBinary /
Then for dev we can just say docker build -t athensdev . with a flag that says just build the first part.
And then for prod, we just build the whole multi-build file as we already can.
Otherwise, we'll probably have to have two Dockerfiles.
If I get the time this week, I can look at Docker to see if that's possible.
@marwan-at-work re: multi-build, we could look at using packer from hashicorp. It allows building multiple images from one config. We could even use it to eventually build VM images.
ref: https://packer.io
Docker does allow for multi-build and stopping at a stage. Using the example you had you could do the following
docker build --target athens-dev -t athens/dev:local .
Then it builds up to the athens-dev stage and tags the image as athens/dev:local. Then we could have a line in the Makefile to spin up this image.
See Docker multi-stage documentation on stopping at build stages
I'll throw another idea onto the pile here - it's possible to use docker as a toolchain that contains everything you need to develop. For example, we can create an image that has buffalo, yarn, go, and whatever else we need in it - let's say it's called gomods/toolchain. Then, we can use that image in our docker-compose file to do builds, tests, etc...
For example, to do a build (which doesn't need any dependency services):
build-proxy:
image: gomods/toolchain
environment:
- GO_ENV=production
- GOPATH=/go
volumes:
- .:/go/src/github.com/gomods/athens
working_dir: /go/src/github.com/gomods/athens/cmd/proxy
command: ["buffalo", "build"]
Then to build, you run docker-compose -p athensbuild up build-proxy. And with running tests, we can link the test service in the compose file with the other services that it relies on (mongo, etc...)
If we have a last step that adds dependencies for tests (including lint, dep etc) we can cover #134 as well
@kaxcode feel free to give this a shot. Feel free to ping me here or on slack :)
@marwan-at-work what do you feel like we're still missing for this issue?
This would be nice to have for v0.1.0. Possible things left to do (according to @marwan-at-work):
Most helpful comment
I'll throw another idea onto the pile here - it's possible to use docker as a toolchain that contains everything you need to develop. For example, we can create an image that has
buffalo,yarn,go, and whatever else we need in it - let's say it's calledgomods/toolchain. Then, we can use that image in our docker-compose file to do builds, tests, etc...For example, to do a build (which doesn't need any dependency services):
Then to build, you run
docker-compose -p athensbuild up build-proxy. And with running tests, we can link thetestservice in the compose file with the other services that it relies on (mongo, etc...)