FROM golang:1.25.0-alpine AS build_base

## Usage:
## docker build . -f Dockerfile.cli-tool -t gokapi-cli
## docker run -it --rm -v gokapi-cli-config:/app/config gokapi-cli

RUN mkdir /compile
COPY go.mod /compile
RUN cd /compile && go mod download
  
COPY . /compile  

RUN cd /compile && go generate ./... && CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/forceu/gokapi/internal/environment.IsDocker=true' -X 'github.com/forceu/gokapi/internal/environment.Builder=Project Docker File' -X 'github.com/forceu/gokapi/internal/environment.BuildTime=$(date)'" -o /compile/gokapi-cli github.com/forceu/gokapi/cmd/cli-uploader

FROM alpine:3.19

COPY --from=build_base /compile/gokapi-cli /app/gokapi-cli
WORKDIR /app

ENTRYPOINT ["/app/gokapi-cli"]
