| # syntax=docker/dockerfile:1 | |
| FROM golang:1.24 | |
| # Set destination for COPY | |
| WORKDIR /app | |
| # Copy the source code. Note the slash at the end, as explained in | |
| # https://docs.docker.com/reference/dockerfile/#copy | |
| COPY *.go ./ | |
| # Download Go modules | |
| RUN go mod init masatrad.com/helloword | |
| RUN go mod download | |
| # Build | |
| RUN CGO_ENABLED=0 GOOS=linux go build -o /helloworld | |
| # Optional: | |
| # To bind to a TCP port, runtime parameters must be supplied to the docker command. | |
| # But we can document in the Dockerfile what ports | |
| # the application is going to listen on by default. | |
| # https://docs.docker.com/reference/dockerfile/#expose | |
| EXPOSE 7860 | |
| # Run | |
| CMD ["/helloworld"] |