|
1 | | -FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.22-alpine as builder |
| 1 | +FROM golang:1.26-alpine AS builder |
| 2 | + |
| 3 | +ARG TARGETPLATFORM |
2 | 4 |
|
3 | 5 | ENV CGO_ENABLED=0 |
4 | 6 |
|
5 | 7 | WORKDIR /src |
6 | | -COPY protoc_plugins/ . |
| 8 | +# https://buf.build/docs/bsr/remote-plugins/custom-plugins/#build-a-docker-image |
| 9 | +RUN test "${TARGETPLATFORM}" = "linux/amd64" || (echo "buf plugin image must be built for linux/amd64" && exit 1) |
| 10 | + |
| 11 | +COPY protoc_plugins/go.mod protoc_plugins/go.sum ./ |
7 | 12 | RUN go mod download |
8 | | -RUN go mod tidy |
9 | 13 |
|
10 | | -RUN go build -trimpath -ldflags "-s" -o protoc-gen-php-grpc-plugin protoc-gen-php-grpc/main.go |
| 14 | +COPY protoc_plugins/ . |
| 15 | + |
| 16 | +RUN go build -trimpath -ldflags "-s -w" -o /out/protoc-gen-php-grpc-plugin ./protoc-gen-php-grpc |
11 | 17 |
|
12 | 18 | FROM scratch |
13 | 19 |
|
14 | | -ARG APP_VERSION="" |
| 20 | +# Supply real metadata at build time, for example: |
| 21 | +# docker build --platform linux/amd64 --build-arg BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" --build-arg APP_VERSION="vX.Y.Z" -f protoc_plugins/Dockerfile . |
| 22 | +ARG APP_VERSION="unknown" |
| 23 | +ARG BUILD_TIME="unknown" |
15 | 24 |
|
16 | 25 | # Runtime dependencies |
17 | 26 | LABEL org.opencontainers.image.title="protoc-gen-php-grpc" |
18 | 27 | LABEL org.opencontainers.image.description="protoc plugin for generating PHP gRPC service stubs" |
19 | 28 | LABEL org.opencontainers.image.url="https://roadrunner.dev" |
20 | 29 | LABEL org.opencontainers.image.source="https://github.com/roadrunner-server/grpc" |
21 | 30 | LABEL org.opencontainers.image.vendor="SpiralScout" |
22 | | -LABEL org.opencontainers.image.version="$APP_VERSION" |
23 | | -LABEL org.opencontainers.image.created="$BUILD_TIME" |
| 31 | +LABEL org.opencontainers.image.version="${APP_VERSION}" |
| 32 | +LABEL org.opencontainers.image.created="${BUILD_TIME}" |
24 | 33 | LABEL org.opencontainers.image.licenses="MIT" |
25 | 34 |
|
26 | | -COPY --from=builder /src/protoc-gen-php-grpc-plugin / |
| 35 | +COPY --from=builder --chown=65532:65532 /out/protoc-gen-php-grpc-plugin /protoc-gen-php-grpc-plugin |
| 36 | + |
| 37 | +USER 65532:65532 |
27 | 38 |
|
28 | 39 | ENTRYPOINT ["/protoc-gen-php-grpc-plugin"] |
0 commit comments