diff --git a/.gitignore b/.gitignore index daf913b..189a123 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ _testmain.go *.exe *.test *.prof + +data/* +cowyo \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ac2c9bf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# First build step +FROM golang:1.9-alpine as builder + +WORKDIR /go/src/cowyo +COPY . . +# Disable crosscompiling +ENV CGO_ENABLED=0 + +# Install git and make, compile and cleanup +RUN apk add --no-cache git make \ + && go get -u github.com/schollz/cowyo \ + && go get -u github.com/jteeuwen/go-bindata/... \ + && make \ + && apk del --purge git make \ + && rm -rf /var/cache/apk* + +# Second build step uses the minimal scratch Docker image +FROM scratch +# Copy the binary from the first step +COPY --from=builder /go/src/cowyo/cowyo /usr/local/bin/cowyo +# Expose data folder +VOLUME /data +EXPOSE 8050 +# Start cowyo listening on any host +CMD ["cowyo", "--host", "0.0.0.0"] \ No newline at end of file diff --git a/Makefile b/Makefile index 03eca63..401ad47 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # make -j4 release VERSION=$(shell git describe) -LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" +LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -a -installsuffix cgo .PHONY: build build: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3249d2b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "2" + +services: + cowyo: + build: . + ports: + - 8050:8050 + volumes: + - ./data:/data \ No newline at end of file