FROM golang:1.20 as build

WORKDIR /code

# Copy code into build container
COPY . /code/

RUN GOOS=linux \
    GOARCH=amd64 \
    CGO_ENABLED=0 \ 
    go build -o build/go-semantic-release.linux_x86_64 -ldflags "-w -s --X main.version=`go-semantic-release next`" \ 
    ./cmd/go-semantic-release/


FROM alpine:3.14

WORKDIR /code

COPY --from=build /code/build/go-semantic-release.linux_x86_64 /usr/local/bin/go-semantic-release

USER 1000

ENTRYPOINT [ "go-semantic-release" ]
