FROM golang:1.14-alpine AS builder
WORKDIR /agentx-loadtest-lunchandlearn
COPY . .
WORKDIR /agentx-loadtest-lunchandlearn/cmd/api

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -mod mod

FROM alpine:latest AS release

RUN apk add curl

WORKDIR /go/bin

COPY --from=builder /go/bin .

RUN apk add -U tzdata && \
    apk add --update --no-cache ca-certificates

# Run commands as non-root user
RUN adduser -S summit
USER summit

EXPOSE 8080

CMD "./api"