# syntax=docker/dockerfile:1

##
## Build
##
FROM golang:1.18-alpine AS build

RUN apk update
RUN apk upgrade
RUN apk add build-base git

WORKDIR /app

COPY ./ ./

RUN go mod tidy
RUN mkdir bin

WORKDIR /app/his

RUN go build -o /app/bin/his

##
## Deploy
##
FROM golang:1.18-alpine

WORKDIR /

COPY ./his/assets /assets
COPY ./his/templates /templates
COPY --from=build /app/bin/his ./his

RUN adduser -D nonroot
USER nonroot:nonroot

# > "logs/$(date +'%Y%m%d_%H%M').log" 2>&1
ENTRYPOINT ["/his"]