FROM xena/go:1.11.4 AS build
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
ENV CGO_ENABLED 0
WORKDIR /site
RUN cd ./cmd/sserver \
 && /root/go/bin/statik -src /site/site.static \
 && go build -mod=vendor -o sserver . \
 && cp sserver /usr/local/bin/sserver

FROM alpine:3.8
COPY CHECKS /app/CHECKS
COPY --from=build /usr/local/bin/sserver /tftk
EXPOSE 80
CMD /tftk
