# Build Stage
# First pull Golang image
FROM golang:1.23.0-alpine as builder
 
# Set environment variable
ENV APP_NAME niki
ENV CMD_PATH main.go

# Add a work directory
WORKDIR /$APP_NAME

## Cache and install dependencies
#COPY go.mod go.sum ./
#RUN go mod download

# Copy app files
COPY . .

# Budild application
RUN CGO_ENABLED=0 go build -mod=vendor -v -o $APP_NAME .

# Run Stage

FROM alpine:3.20 as Runtime

 
# Set environment variable
ENV APP_NAME niki
 
# Copy only required data into this image
COPY --from=builder /$APP_NAME .
 
# Expose application port
EXPOSE 8313
 
# Start app
CMD ./$APP_NAME