Skip to content

Commit

Permalink
Merge branch 'main' into osun/grpc-gateway-v2.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversun9 committed Jul 31, 2024
2 parents 96cd0c1 + 3a248af commit 77198b6
Show file tree
Hide file tree
Showing 20 changed files with 738 additions and 7 deletions.
15 changes: 12 additions & 3 deletions internal/cmd/fetcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import (
)

var (
bazelDownloadRegexp = regexp.MustCompile(`bazelbuild/bazel/releases/download/[^/]+/bazel-[^-]+-linux`)
bazelImageName = "gcr.io/bazel-public/bazel"
errNoVersions = errors.New("no versions found")
bazelDownloadRegexp = regexp.MustCompile(`bazelbuild/bazel/releases/download/[^/]+/bazel-[^-]+-linux`)
bazelImageName = "gcr.io/bazel-public/bazel"
dockerfileImageName = "docker/dockerfile"
dockerfileSyntaxPrefix = "# syntax=docker/dockerfile:"
errNoVersions = errors.New("no versions found")
)

func main() {
Expand Down Expand Up @@ -306,6 +308,10 @@ func copyFile(
if latestBazelVersion == "" {
return fmt.Errorf("failed to find latest version for bazel image %q", bazelImageName)
}
latestDockerfileVersion := latestBaseImages.ImageVersion(dockerfileImageName)
if latestDockerfileVersion == "" {
return fmt.Errorf("failed to find latest version for dockerfile image %q", bazelImageName)
}
s := bufio.NewScanner(srcFile)
for s.Scan() {
line := strings.ReplaceAll(s.Text(), prevVersion, newVersion)
Expand Down Expand Up @@ -335,6 +341,9 @@ func copyFile(
}
}
}
if isDockerfile && strings.HasPrefix(line, dockerfileSyntaxPrefix) {
line = dockerfileSyntaxPrefix + latestDockerfileVersion
}
if _, err := fmt.Fprintln(destFile, line); err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/bufbuild/es/v2.0.0/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!package*.json
21 changes: 21 additions & 0 deletions plugins/bufbuild/es/v2.0.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1.9
FROM node:20.16.0-bookworm AS build
WORKDIR /app
COPY --link package*.json .
RUN npm ci \
&& find node_modules/typescript ! -name 'typescript.js' ! -name 'package.json' -type f -exec rm -f {} + \
&& find node_modules/typescript -depth -type d -empty -delete \
&& ./node_modules/.bin/esbuild ./node_modules/.bin/protoc-gen-es --bundle --external:typescript --platform=node --outfile=protoc-gen-es.js

FROM gcr.io/distroless/nodejs20-debian12:latest@sha256:3d8ce4f2928114e4c1a89c1fd327064b8a0aea40fe967793fb3f9dbea2213a39 AS node

FROM gcr.io/distroless/cc-debian12:latest@sha256:3b75fdd33932d16e53a461277becf57c4f815c6cee5f6bc8f52457c095e004c8 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=node --chmod=0755 /nodejs/bin/node /nodejs/bin/node
COPY --link --from=build --chmod=0755 /app/protoc-gen-es.js /app/protoc-gen-es.js
COPY --link --from=build /app/node_modules/typescript /app/node_modules/typescript
USER nobody
ENTRYPOINT ["/nodejs/bin/node"]
CMD [ "/app/protoc-gen-es.js" ]
18 changes: 18 additions & 0 deletions plugins/bufbuild/es/v2.0.0/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: v1
name: buf.build/bufbuild/es
plugin_version: v2.0.0
source_url: https://github.com/bufbuild/protobuf-es
integration_guide_url: https://github.com/bufbuild/protobuf-es#quickstart
description: Base types for TypeScript/JavaScript for use in web browsers and Node.js. Generates message and enum types.
output_languages:
- javascript
- typescript
registry:
npm:
import_style: module
rewrite_import_path_suffix: pb.js
deps:
- package: '@bufbuild/protobuf'
version: ^2.0.0
spdx_license_id: Apache-2.0
license_url: https://github.com/bufbuild/protobuf-es/blob/v2.0.0/LICENSE
Loading

0 comments on commit 77198b6

Please sign in to comment.