# Builder
FROM golang:alpine

WORKDIR /go/src/app
COPY src ./

ARG BIN_OUTPUT=/go/bin
ARG GO_SERVER=cmd/server/main.go
ARG GO_MIGRATE=cmd/migrate/main.go
ARG GO_WORKER=cmd/worker/main.go
ARG GO_HEALTH=cmd/health/main.go


RUN export CGO_ENABLED=0 ; export GOOS=linux ; export GOARCH=amd64 && \
    go build -ldflags="-w -s" -o "$BIN_OUTPUT/server" $GO_SERVER && \
    go build -ldflags="-w -s" -o "$BIN_OUTPUT/migrate" $GO_MIGRATE && \
    go build -ldflags="-w -s" -o "$BIN_OUTPUT/worker" $GO_WORKER && \
    go build -ldflags="-w -s" -o "$BIN_OUTPUT/health" $GO_HEALTH