-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.migrate
More file actions
30 lines (21 loc) · 806 Bytes
/
Copy pathDockerfile.migrate
File metadata and controls
30 lines (21 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# syntax=docker/dockerfile:1.7
# Builds the standalone migration runner (cmd/migrate) together with the SQL
# migration files, so `docker compose` can apply migrations before the API starts.
# Migrations are NOT embedded in the binary, so the db/migrations directory is
# copied into the final image alongside the binary.
FROM golang:1.26-alpine AS builder
WORKDIR /src
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -trimpath -ldflags="-s -w" -o /out/migrate ./cmd/migrate
FROM alpine:3.20
WORKDIR /app
COPY --from=builder /out/migrate /app/migrate
COPY --from=builder /src/db/migrations /app/db/migrations
# Default command is `up`; override in compose if needed (e.g. `version`, `down`).
ENTRYPOINT ["/app/migrate"]
CMD ["up"]