FROM golang:alpine as gobuild

ENV GOOS linux
ENV GOARCH amd64

RUN apk add --no-cache git pkgconfig ncurses-dev ncurses-static gcc libc-dev

WORKDIR /go/src/login-app

ADD cmd ./

RUN go get -d -v
RUN go build -v -tags netgo -ldflags '-w -extldflags "-static -lpanelw -lncursesw"'


FROM alpine
MAINTAINER Pierre-Olivier Mercier <nemunaire@nemunai.re>

EXPOSE 8081

COPY --from=gobuild /go/src/login-app/login-app /bin/login-app
COPY --from=gobuild /etc/terminfo/l/linux /etc/terminfo/l/linux
COPY --from=gobuild /usr/share/udhcpc/default.script /usr/share/udhcpc/default.script

ENTRYPOINT ["/bin/login-app"]
