ARG BUILDER_IMAGE="registry.access.redhat.com/ubi9/go-toolset:1.22.5-1730550521"
ARG BASE_IMAGE="registry.access.redhat.com/ubi9-micro:9.5-1731934928"

FROM ${BUILDER_IMAGE} AS builder

WORKDIR /opt/app-root/src

COPY ./pathservice ./

# Build the Go app
RUN go build -o bin/pathservice

# Start a new stage from scratch
FROM ${BASE_IMAGE}

# Copy the binary from the previous stage
COPY --from=builder /opt/app-root/src/bin/pathservice /pathservice

# Expose the port 4000 to the outside world
EXPOSE 4000

# Command to run the executable
CMD ["/pathservice"]
