| 1 | # syntax=docker/dockerfile:1 |
| 2 | # Build context: repo root |
| 3 | # docker build -f packages/db/Dockerfile -t struxa-migrate . |
| 4 | FROM golang:1.24-alpine AS builder |
| 5 | WORKDIR /app |
| 6 | ENV GOFLAGS=-mod=mod |
| 7 | COPY packages/db/migrate/go.mod ./ |
| 8 | RUN go mod download |
| 9 | COPY packages/db/migrate/ ./ |
| 10 | RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o migrate . |
| 11 | |
| 12 | FROM gcr.io/distroless/static:nonroot |
| 13 | COPY --from=builder /app/migrate /migrate |
| 14 | COPY packages/db/src/migrations/ /migrations/ |
| 15 | ENV MIGRATIONS_DIR=/migrations |
| 16 | ENTRYPOINT ["/migrate"] |