Skip to content

Commit a6a1127

Browse files
committed
multi: use Docker for proto compilation
To remove the need for a dev to install a specific version of protoc we now use a docker image for compiling the protos.
1 parent ccb78a7 commit a6a1127

File tree

6 files changed

+38
-45
lines changed

6 files changed

+38
-45
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ jobs:
147147
lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
148148
lnd-${{ runner.os }}-download-
149149
150-
- name: install protoc and protobuf libraries
151-
run: ./scripts/install_protoc.sh
152-
153150
- name: get yarn cache dir
154151
id: yarn-cache-dir
155152
run: echo "::set-output name=dir::$(yarn cache dir)"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ list:
193193

194194
protos:
195195
@$(call print, "Compiling protos.")
196-
cd ./app; yarn protos
196+
cd proto; ./gen_protos_docker.sh
197197

198198
protos-check: protos
199199
@$(call print, "Verifying compiled protos.")

doc/compile.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,13 @@ Terminal are updated.
7676

7777
To compile the proto files into JS/TS code, follow the following steps:
7878

79-
1. Install `protoc` **v3.4.0** if you do not already have it installed. Follow the
80-
instructions in
81-
[this guide](https://github.com/lightningnetwork/lnd/tree/master/lnrpc#generate-protobuf-definitions).
82-
Be sure to install the specific **v3.4.0** version of `protoc`. Newer versions will not
83-
work properly.
84-
85-
> Note: if you are running on a Mac, you only need to perform step 1
86-
1. Run the following command to download the proto files from each repo and compile the
87-
JS/TS code using the updated protos.
88-
```shell script
89-
$ cd app
90-
$ yarn protos
79+
1. Install `docker` if you do not already have it installed. Follow the
80+
instructions in [this guide](https://docs.docker.com/get-docker/).
81+
82+
1. Run the following command to download the proto files from each repo and
83+
compile the JS/TS code using the updated protos.
84+
```shell
85+
$ make protos
9186
```
9287
1. Fix any typing, linting, or unit test failures introduced by the update. Run the
9388
commands below to find and fix these errors in the app code.

proto/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Start with a NodeJS base image that also contains yarn.
2+
FROM node:12.17.0-buster as nodejsbuilder
3+
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
protobuf-compiler='3.6*' \
7+
clang-format='1:7.0*'
8+
9+
RUN mkdir /build
10+
11+
WORKDIR /build
12+
13+
CMD ["/bin/bash", "-c", "cd app && yarn install && yarn protos"]

proto/gen_protos_docker.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Directory of the script file, independent of where it's called from.
6+
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
7+
8+
echo "Building protobuf compiler docker image..."
9+
docker build -q -t lit-protobuf-builder .
10+
11+
echo "Compiling and formatting *.proto files..."
12+
docker run \
13+
--rm \
14+
--user $UID:$UID \
15+
-e UID=$UID \
16+
-v "$DIR/../:/build" \
17+
lit-protobuf-builder

scripts/install_protoc.sh

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

0 commit comments

Comments
 (0)