Skip to content

Commit

Permalink
Reduce layers in prost plugins (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren authored Jun 11, 2024
1 parent 2f9c5f0 commit a5108da
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 21 deletions.
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-prost-crate/v0.4.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.76.0-alpine3.19 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-prost-crate --version 0.4.0 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-prost-crate /protoc-gen-prost-crate
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-prost-crate /protoc-gen-prost-crate
USER nobody
ENTRYPOINT ["/protoc-gen-prost-crate"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-prost-serde/v0.3.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.76.0-alpine3.19 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-prost-serde --version 0.3.0 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-prost-serde /protoc-gen-prost-serde
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-prost-serde /protoc-gen-prost-serde
USER nobody
ENTRYPOINT ["/protoc-gen-prost-serde"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-prost/v0.2.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.70.0-alpine3.18 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-prost --version 0.2.3 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
USER nobody
ENTRYPOINT ["/protoc-gen-prost"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-prost/v0.3.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.76.0-alpine3.19 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-prost --version 0.3.0 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
USER nobody
ENTRYPOINT ["/protoc-gen-prost"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-prost/v0.3.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.76.0-alpine3.19 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-prost --version 0.3.1 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-prost /protoc-gen-prost
USER nobody
ENTRYPOINT ["/protoc-gen-prost"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-tonic/v0.3.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.70.0-alpine3.18 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-tonic --version 0.3.0 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-tonic /protoc-gen-tonic
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-tonic /protoc-gen-tonic
USER nobody
ENTRYPOINT ["/protoc-gen-tonic"]
9 changes: 6 additions & 3 deletions plugins/community/neoeinstein-tonic/v0.4.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1.7
FROM rust:1.76.0-alpine3.19 as builder
RUN apk add --no-cache musl-dev
WORKDIR /app
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \
cargo install protoc-gen-tonic --version 0.4.0 --locked --root /app

FROM gcr.io/distroless/static
COPY --from=builder /app/bin/protoc-gen-tonic /protoc-gen-tonic
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=builder /app/bin/protoc-gen-tonic /protoc-gen-tonic
USER nobody
ENTRYPOINT ["/protoc-gen-tonic"]

0 comments on commit a5108da

Please sign in to comment.