Skip to content

Commit

Permalink
[cw|frenata#5] add Dockerfile to project root
Browse files Browse the repository at this point in the history
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
  • Loading branch information
connorwalsh committed Mar 10, 2018
1 parent 6dc9f01 commit bbdbb86
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit bbdbb86

Please sign in to comment.