FROM xena/go:1.10
RUN apk --no-cache add make git
RUN mkdir -p /usr/local/src \
 && git clone https://github.com/jroimartin/sw /usr/local/src/sw \
 && cd /usr/local/src/sw && make && make install PREFIX=/usr/local \
 && GOBIN=/usr/local/bin go get github.com/russross/blackfriday-tool \
 && go get github.com/rakyll/statik
COPY . /site
RUN set -x \
 && cd /site \
 && sw site

COPY ./vendor/ /root/go/src
COPY ./cmd /root/go/src/git.xeserv.us/xena/tulpaforce.tk/cmd
ENV CGO_ENABLED 0
RUN cd /root/go/src/git.xeserv.us/xena/tulpaforce.tk/cmd/sserver \
 && /root/go/bin/statik -src /site/site.static \
 && go build \
 && GOBIN=/usr/local/bin go install

FROM alpine:3.7
COPY --from=0 /usr/local/bin/sserver /tftk
EXPOSE 80
CMD /tftk
