From bbdbb8688d73c033a91259b000261b30e76e70f1 Mon Sep 17 00:00:00 2001 From: connorwalsh Date: Fri, 9 Mar 2018 19:29:03 -0500 Subject: [PATCH] [cw|#5] add Dockerfile to project root Major Changes: * add Dockerfile for building API server image TODO: * add docker-compose.yml template to project root * add build.sh script for buliding both docker images in repo * add (possibly) a run.sh script for running both images * add test for ensuring docker build/run works * exec (eventually) test code in API server on container start --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..abb58be --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM golang:1.9-alpine as server + +# GOPATH = /go in the golang image +# also $GOPATH/bin has been added to path + +WORKDIR /go/src/ + +# copy API server src to be compiled +COPY API/ ./ + +# currently, we need to install several dependencies +# note that we must install Docker, but when we run the container, we must +# mount the /var/run/docker.sock of the host onto the container so the host +# docker daemon spins up sibling containers (as opposed to Docker in Docker) +# +# TODO (cw|3.9.18) once we remove the dependency on gb, we will only need to +# install docker here. +RUN apk update && \ + apk add --no-cache git && \ + go get github.com/constabulary/gb/... && \ + apk del git && \ + apk add docker + +# compile and install server binary within container +RUN gb build && \ + mv ./bin/compilebox /go/bin + +FROM alpine + +WORKDIR /bin/ + +# copy over single binary from build stage --^ +COPY --from=server /go/bin/compilebox . + +EXPOSE 6666 + +# run comilebox API server +CMD ["compilebox"]