diff --git a/.gitignore b/.gitignore index 67040f2e7..14b4adaac 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ /temporal /temporal.exe +# Goreleaser output +/dist + # Used by IDE /.idea /.vscode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a35a33514..122c7140f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,3 +46,18 @@ Note that inclusion of space characters in the value supplied via `-ldflags` is Here's an example that adds branch info from a local repo to the version string, and includes a space character: go build -ldflags "-X 'github.com/temporalio/cli/temporalcli.buildInfo=ServerBranch $(git -C ../temporal rev-parse --abbrev-ref HEAD)'" -o temporal ./cmd/temporal/main.go + +## Building Docker image + +Docker image build requires [Goreleaser](https://goreleaser.com/) to build the binaries first, although it doesn't use +Goreleaser for the Docker image itself. + +First, run the Goreleaser build: + + goreleaser build --snapshot --clean + +Then, run the Docker build using the following command: + + docker build --tag temporalio/temporal:snapshot --platform= . + +Currently only `linux/amd64` and `linux/arm64` platforms are supported. diff --git a/Dockerfile b/Dockerfile index 898552833..05c3938a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,12 @@ -FROM golang:1.24-bookworm AS builder - -WORKDIR /app - -# Copy everything -COPY . ./ - -# Build -RUN go build ./cmd/temporal - -# Use slim container for running -FROM debian:bookworm-slim -RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - ca-certificates && \ - rm -rf /var/lib/apt/lists/* - -# Copy binary -COPY --from=builder /app/temporal /app/temporal - -# Set CLI as primary entrypoint -ENTRYPOINT ["/app/temporal"] +FROM --platform=$BUILDARCH scratch AS dist +COPY ./dist/nix_linux_amd64_v1/temporal /dist/amd64/temporal +COPY ./dist/nix_linux_arm64/temporal /dist/arm64/temporal + +FROM alpine:3.22 +ARG TARGETARCH +RUN apk add --no-cache ca-certificates +COPY --from=dist /dist/$TARGETARCH/temporal /usr/local/bin/temporal +RUN adduser -u 1000 -D temporal +USER temporal + +ENTRYPOINT ["temporal"]