# CI runner image: gitmote-runner + nektos/act, run as a Scaleway Serverless Job
# (one definition serves all repos; env injected per job at trigger, per stage 3).
#
# act runs in SELF-HOSTED mode here (GITMOTE_ACT_PLATFORMS below): Serverless Jobs
# have no Docker daemon, so act executes the workflow steps directly in THIS
# container rather than nesting a per-job container. The Job is a fresh, ephemeral,
# scale-to-zero container, so it is the sandbox. Tools workflows need (git, node,
# bash) must therefore live in this image.

# syntax=docker/dockerfile:1
FROM golang:1.26-bookworm AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/gitmote-runner ./cmd/gitmote-runner

FROM debian:bookworm-slim
ARG ACT_VERSION=0.2.89
RUN apt-get update \
 && apt-get install -y --no-install-recommends git ca-certificates curl bash tar \
 && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
 && apt-get install -y --no-install-recommends nodejs \
 && curl -fsSL "https://github.com/nektos/act/releases/download/v${ACT_VERSION}/act_Linux_x86_64.tar.gz" \
      | tar -xz -C /usr/local/bin act \
 && apt-get purge -y curl \
 && apt-get autoremove -y \
 && rm -rf /var/lib/apt/lists/* \
 && act --version && node --version && git --version

COPY --from=build /out/gitmote-runner /usr/local/bin/gitmote-runner

# Self-hosted execution for the common ubuntu labels — no Docker-in-Docker.
ENV GITMOTE_ACT_PLATFORMS="ubuntu-latest=-self-hosted,ubuntu-22.04=-self-hosted,ubuntu-24.04=-self-hosted"

ENTRYPOINT ["gitmote-runner"]
