Skip to content

Commit 0b0e60a

Browse files
committed
legacy cleanup
1 parent 991e8c3 commit 0b0e60a

File tree

13 files changed

+68
-1081
lines changed

13 files changed

+68
-1081
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
- name: Build and Publish to Docker Hub
4545
uses: docker/build-push-action@v3
4646
with:
47-
context: ./context
48-
file: ./Dockerfile
47+
context: .
48+
file: Dockerfile
4949
platforms: linux/amd64,linux/arm64
5050
# platforms: linux/amd64,linux/arm64,linux/arm/v7
5151
# tags: "themakers/protoc:${{ github.event.release.tag_name }}"

Dockerfile

Lines changed: 9 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,24 @@
11
################################################################
22
#### protoc container
3-
FROM golang:1.19-bullseye as protoc
4-
5-
ENV DEBIAN_FRONTEND noninteractive
6-
ARG TARGETARCH
7-
8-
WORKDIR /protoc
9-
10-
####
11-
#### protoc + protoc-gen-grpc-web
12-
####
13-
14-
RUN \
15-
apt-get update \
16-
&& apt-get install -y \
17-
wget unzip \
18-
&& apt-get clean \
19-
&& rm -rf /var/lib/apt/lists/*
20-
21-
# https://github.com/protocolbuffers/protobuf/releases/
22-
ARG PROTOC_VERSION=21.12
23-
ARG PROTOC_VERSION_GITHUB_RELEASE=v21.12
24-
25-
ARG PROTOC_GEN_GRPC_WEB_VERSION=1.4.2
26-
27-
ARG PROTOC_VERSION
3+
FROM golang:1.23-alpine AS go
284

5+
ENV CGO_ENABLED=0
296
RUN \
30-
case $TARGETARCH in \
31-
amd64) \
32-
export PROTOC_ARCH=x86_64 \
33-
;; \
34-
arm64) \
35-
export PROTOC_ARCH=aarch_64 \
36-
;; \
37-
*) \
38-
echo "Unsupported architecture >$TARGETARCH<" &&\
39-
exit 1 \
40-
;; \
41-
esac &&\
42-
export PROTOC_ARCHIVE=protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip &&\
43-
wget https://github.com/protocolbuffers/protobuf/releases/download/${PROTOC_VERSION_GITHUB_RELEASE}/${PROTOC_ARCHIVE} &&\
44-
unzip ${PROTOC_ARCHIVE} -d /protoc &&\
45-
rm ${PROTOC_ARCHIVE}
46-
47-
# https://github.com/protocolbuffers/protobuf/releases/download/v21.0-rc-2/protoc-21.0-rc-2-linux-x86_64.zip
48-
# https://github.com/protocolbuffers/protobuf/releases/download/v21.0-rc2/protoc-21.0-rc-2-linux-x86_64.zip
49-
50-
ARG PROTOC_GEN_GRPC_WEB_VERSION
51-
RUN wget -O /protoc/bin/protoc-gen-grpc-web https://github.com/grpc/grpc-web/releases/download/${PROTOC_GEN_GRPC_WEB_VERSION}/protoc-gen-grpc-web-${PROTOC_GEN_GRPC_WEB_VERSION}-linux-x86_64
52-
RUN chmod +x /protoc/bin/protoc-gen-grpc-web
53-
54-
####
55-
#### golang tools
56-
####
57-
58-
COPY / /protoc
59-
60-
RUN \
61-
git clone https://github.com/googleapis/googleapis.git --branch master --single-branch /protoc/googleapis &&\
62-
rm -rf /protoc/googleapis/.git
63-
64-
ENV GOBIN=/protoc/bin/
65-
RUN go install \
66-
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
67-
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
68-
google.golang.org/protobuf/cmd/protoc-gen-go \
69-
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
70-
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc \
71-
\
72-
github.com/bufbuild/buf/cmd/buf \
73-
github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go \
74-
github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking \
75-
github.com/bufbuild/buf/cmd/protoc-gen-buf-lint
76-
7+
go install github.com/bufbuild/buf/cmd/buf@latest &&\
8+
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest &&\
9+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest &&\
10+
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest
7711

7812

7913
################################################################
8014
#### Final container
81-
FROM debian:bullseye
82-
ENV DEBIAN_FRONTEND noninteractive
15+
FROM node:lts-alpine AS final
8316

8417
WORKDIR /protoc
8518

86-
COPY --from=protoc /protoc /protoc
19+
COPY --from=go /go/bin /usr/local/bin
8720

8821
RUN \
89-
apt-get update &&\
90-
apt-get install -y curl clang-format &&\
91-
curl -sL https://deb.nodesource.com/setup_16.x | bash - &&\
92-
apt-get install -y nodejs &&\
93-
apt-get clean &&\
94-
rm -rf /var/lib/apt/lists/* &&\
95-
\
96-
npm install &&\
97-
npm run install-hack &&\
98-
\
99-
chmod -R +x /protoc/bin &&\
100-
mv /protoc/bin/protoc /protoc/bin/protoc-original &&\
101-
mv /protoc/bin/* /bin/ &&\
102-
mv /protoc/protoc /bin/ &&\
103-
ln -s /protoc/node_modules/.bin/protoc-gen-connect-web /bin/ &&\
104-
ln -s /protoc/node_modules/.bin/protoc-gen-es /bin/ &&\
105-
ln -s /protoc/node_modules/.bin/protoc-gen-ts /bin/ &&\
106-
ln -s /protoc/node_modules/.bin/protoc-gen-ts_proto /bin/ &&\
107-
ln -s /protoc/pbjs /bin/pbjs &&\
108-
ln -s /protoc/pbts /bin/pbts &&\
109-
\
110-
chmod -R 0777 /protoc
111-
112-
# https://superuser.com/questions/1409618/renaming-a-file-with-mv-cannot-move-to-a-subdirectory-of-itself
22+
npm install -g @connectrpc/protoc-gen-connect-es@"^1.0.0" @bufbuild/protoc-gen-es@"^1.0.0"
11323

11424
WORKDIR /mnt

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ export BUILDKIT_PROGRESS=plain
66

77
.DEFAULT:
88
build:
9-
# docker buildx create --use --name themakers
10-
docker buildx build --rm --progress=plain --builder=themakers --platform linux/amd64,linux/arm64 --file Dockerfile --tag themakers/protoc:latest context
9+
docker build --rm \
10+
--progress=plain \
11+
--tag themakers/protoc:local \
12+
--target final \
13+
- < Dockerfile
14+
1115

1216
run: build
13-
docker run --rm -it themakers/protoc:latest /bin/bash
17+
docker run --rm -it themakers/protoc:local /bin/sh
1418

15-
publish: build
16-
docker image push themakers/protoc:latest
19+
#publish: build
20+
# docker image push themakers/protoc:latest

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# protoc
22

3+
4+
## Usage example
5+
6+
#### **generate.sh**
7+
```bash
8+
docker run \
9+
--rm -i \
10+
-u "$(id -u):$(id -g)" \ # To match the rights of the generated files with the rights of your user
11+
-e USER="$USER" \
12+
-v /etc/passwd:/etc/passwd:ro \ # To make container's user name match your system user name
13+
-v "$PWD:$PWD":rw \ # Mount current directory
14+
-v "$HOME/.cache:$HOME/.cache":rw \ # Mount ~/.cache directory (required by the `buf` tool)
15+
--workdir "$PWD" \ # Current working directory
16+
docker.io/themakers/protoc:v1.0.11 \
17+
/bin/bash <<- "EOF"
18+
19+
# Format .proto files using clang
20+
find ./protocol -type f -name "*.proto" | xargs clang-format -i
21+
22+
protoc \
23+
-I /protoc/include \
24+
--proto_path=protocol \
25+
\
26+
--connect-web_opt=target=ts,ts_nocheck=false \
27+
--es_opt=target=ts,ts_nocheck=false \
28+
\
29+
--connect-web_out=src/protocol \
30+
--es_out=src/protocol \
31+
\
32+
$(find ./protocol -type f -name '*.proto' | sed -e 's/^\.\/protocol\///')
33+
34+
EOF
35+
```
36+
#### **.clang-format**
37+
```clang
38+
---
39+
UseTab: Never
40+
BasedOnStyle: Google
41+
---
42+
Language: Proto
43+
AlignConsecutiveDeclarations: true
44+
AlignConsecutiveAssignments: true
45+
ReflowComments: true
46+
ColumnLimit: 140
47+
```
48+
49+
50+
351
What's in the package:
452
- [protoc (github.com/protocolbuffers/protobuf)](https://github.com/protocolbuffers/protobuf)
553
- [protoc-gen-go (google.golang.org/protobuf/cmd/protoc-gen-go)](https://github.com/protocolbuffers/protobuf-go/tree/master/cmd/protoc-gen-go)

context/.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

context/go.mod

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)