#####################
## 1. Build server ##
#####################
FROM golang:1.17 AS build-server

WORKDIR /project
COPY . .

ENV CGO_ENABLED 0

RUN go mod download
RUN go build -ldflags "-w -s" -o /build/lucifer cmd/server/main.go



###################
## 2. Run server ##
###################
FROM alpine:3.14.2

# Add results from previous builds
COPY --from=build-server /build/lucifer /usr/bin/lucifer

RUN apk add --no-cache tzdata

# Run server
CMD lucifer