FROM golang:1.24.7 AS build
ARG GIT_COMMIT=unknown
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
    --mount=type=cache,target=/root/.cache/go-build \
    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -trimpath -ldflags="-s -w -X main.commit=${GIT_COMMIT}" \
    -o /out/server ./server/cmd/marka-server

FROM scratch
WORKDIR /app
COPY --from=build /out/server /app/server
COPY --from=build /src/server/playground /app/playground
USER 65532:65532
EXPOSE 8080
CMD ["/app/server","-root=/app/data","-addr=:8080","-playground-root=/app/playground"]

