mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
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.
This commit is contained in:
parent
ccb78a758a
commit
a6a1127cf4
6 changed files with 38 additions and 45 deletions
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
|
|
@ -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)"
|
||||
|
|
|
|||
2
Makefile
2
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.")
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
13
proto/Dockerfile
Normal file
13
proto/Dockerfile
Normal file
|
|
@ -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"]
|
||||
17
proto/gen_protos_docker.sh
Executable file
17
proto/gen_protos_docker.sh
Executable file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue