diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 13882ffb..21e7b851 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -147,9 +147,6 @@ jobs: lnd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }} lnd-${{ runner.os }}-download- - - name: install protoc and protobuf libraries - run: ./scripts/install_protoc.sh - - name: get yarn cache dir id: yarn-cache-dir run: echo "::set-output name=dir::$(yarn cache dir)" diff --git a/Makefile b/Makefile index 37e99973..0ed017c9 100644 --- a/Makefile +++ b/Makefile @@ -193,7 +193,7 @@ list: protos: @$(call print, "Compiling protos.") - cd ./app; yarn protos + cd proto; ./gen_protos_docker.sh protos-check: protos @$(call print, "Verifying compiled protos.") diff --git a/doc/compile.md b/doc/compile.md index 33632b5b..501994e8 100644 --- a/doc/compile.md +++ b/doc/compile.md @@ -76,18 +76,13 @@ Terminal are updated. To compile the proto files into JS/TS code, follow the following steps: -1. Install `protoc` **v3.4.0** if you do not already have it installed. Follow the - instructions in - [this guide](https://github.com/lightningnetwork/lnd/tree/master/lnrpc#generate-protobuf-definitions). - Be sure to install the specific **v3.4.0** version of `protoc`. Newer versions will not - work properly. - - > Note: if you are running on a Mac, you only need to perform step 1 -1. Run the following command to download the proto files from each repo and compile the - JS/TS code using the updated protos. - ```shell script - $ cd app - $ yarn protos +1. Install `docker` if you do not already have it installed. Follow the + instructions in [this guide](https://docs.docker.com/get-docker/). + +1. Run the following command to download the proto files from each repo and + compile the JS/TS code using the updated protos. + ```shell + $ make protos ``` 1. Fix any typing, linting, or unit test failures introduced by the update. Run the commands below to find and fix these errors in the app code. diff --git a/proto/Dockerfile b/proto/Dockerfile new file mode 100644 index 00000000..9ec83b31 --- /dev/null +++ b/proto/Dockerfile @@ -0,0 +1,13 @@ +# Start with a NodeJS base image that also contains yarn. +FROM node:12.17.0-buster as nodejsbuilder + +RUN apt-get update && apt-get install -y \ + git \ + protobuf-compiler='3.6*' \ + clang-format='1:7.0*' + +RUN mkdir /build + +WORKDIR /build + +CMD ["/bin/bash", "-c", "cd app && yarn install && yarn protos"] diff --git a/proto/gen_protos_docker.sh b/proto/gen_protos_docker.sh new file mode 100755 index 00000000..6f598c9e --- /dev/null +++ b/proto/gen_protos_docker.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Directory of the script file, independent of where it's called from. +DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" + +echo "Building protobuf compiler docker image..." +docker build -q -t lit-protobuf-builder . + +echo "Compiling and formatting *.proto files..." +docker run \ + --rm \ + --user $UID:$UID \ + -e UID=$UID \ + -v "$DIR/../:/build" \ + lit-protobuf-builder diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh deleted file mode 100755 index 562ab055..00000000 --- a/scripts/install_protoc.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# Abort on error (-e) and print commands (-v). -set -ev - -# See README.md in lnrpc (of the lnd repository) why we need these specific -# versions/commits. -PROTOC_VERSION=3.4.0 - -# This script is specific to GitHub Actions so we only need to support linux x64. -PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" -PROTOC_DL_CACHE_DIR="${DOWNLOAD_CACHE:-/tmp/download_cache}/protoc" - -# install_protoc copies the cached protoc binary to the $PATH or downloads it -# if no cached version is found. -install_protoc() { - if [ -f "${PROTOC_DL_CACHE_DIR}/bin/protoc" ]; then - echo "Using cached version of protoc" - else - wget -O /tmp/protoc.zip $PROTOC_URL - mkdir -p "${PROTOC_DL_CACHE_DIR}" - unzip -o /tmp/protoc.zip -d "${PROTOC_DL_CACHE_DIR}" - chmod -R a+rx "${PROTOC_DL_CACHE_DIR}/" - fi - sudo cp "${PROTOC_DL_CACHE_DIR}/bin/protoc" /usr/local/bin - sudo cp -r "${PROTOC_DL_CACHE_DIR}/include" /usr/local -} - -install_protoc