Files
flock/Dockerfile
T
Donavan Fritz e0ae98ad6c
Build flock Image / build (push) Has been cancelled
ci: move go test into Dockerfile build stage
The runner runs jobs via act + DinD; `docker run -v "$PWD:/src"` from
inside the job container mounts the runner-job filesystem, not the
docker daemon's host fs, so the mount appears empty and `go test ./...`
fails with "directory prefix . does not contain main module".

Run tests in the same container that builds — same workspace, no mount.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-04-24 21:19:10 -05:00

27 lines
828 B
Docker

FROM golang:1.26-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ ./cmd/
COPY pkg/ ./pkg/
# Tests run inside the build container — Gitea/act DinD makes mount-based
# `docker run -v $PWD:/src` unreliable for native go test from the runner job.
RUN go test -count=1 ./...
ARG GIT_SHA=unknown
RUN CGO_ENABLED=0 go build -trimpath \
-ldflags="-s -w -X main.gitSHA=${GIT_SHA}" \
-o /out/flock ./cmd/flock \
&& CGO_ENABLED=0 go build -trimpath \
-ldflags="-s -w -X main.gitSHA=${GIT_SHA}" \
-o /out/flock-agent ./cmd/flock-agent
FROM alpine:3.21
RUN apk add --no-cache iproute2 ca-certificates
COPY --from=build /out/flock /usr/local/bin/flock
COPY --from=build /out/flock-agent /usr/local/bin/flock-agent
ENTRYPOINT ["/usr/local/bin/flock-agent"]