# Build and run Circuit from source using Go modules in a GOPATH-style workspace
FROM golang:1.26-bookworm
# Use a GOPATH-based workspace but enable Go modules for dependency management
ENV GOPATH=/go/workspace
ENV PATH=$PATH:/go/workspace/bin
ENV GO111MODULE=on
# Install required system dependencies
RUN apt-get update -qq && apt-get install -yqq mercurial git gcc make
# Copy the repository into the GOPATH-based workspace
WORKDIR /go/workspace/src/github.com/gocircuit/circuit
COPY . .
# Initialize go.mod and tidy dependencies
RUN go mod init github.com/gocircuit/circuit || true
RUN go mod tidy
# Build the project from source using the nix target (produces GOPATH/bin/circuit)
RUN make nix
# Run the built Circuit CLI by default
CMD ["circuit", "start"]