-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created dockerized workflow for building protobufs. (#734)
Signed-off-by: Cody Littley <[email protected]>
- Loading branch information
1 parent
14ca646
commit 2c75d5d
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM golang:1.21.12-bookworm | ||
|
||
# Install core dependencies | ||
RUN apt update | ||
RUN apt install -y wget unzip bash | ||
|
||
# Set up user | ||
RUN useradd -m -s /bin/bash user | ||
USER user | ||
WORKDIR /home/user | ||
# Remove default crud | ||
RUN rm .bashrc | ||
RUN rm .bash_logout | ||
RUN rm .profile | ||
|
||
# Install protoc | ||
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v23.4/protoc-23.4-linux-aarch_64.zip | ||
RUN mkdir protoc | ||
RUN cd protoc && unzip ../*.zip | ||
RUN rm ./*.zip | ||
|
||
# Setup PATH | ||
RUN touch ~/.bashrc | ||
RUN echo 'export PATH=~/protoc/bin:$PATH' >> ~/.bashrc | ||
RUN echo 'export GOPATH=/go' >> ~/.bashrc | ||
RUN echo 'export PATH=/usr/local/go/bin:$PATH' >> ~/.bashrc | ||
|
||
# Install go protobuf extensions | ||
RUN bash -c 'source ~/.bashrc && go install google.golang.org/protobuf/cmd/[email protected]' | ||
RUN bash -c 'source ~/.bashrc && go install google.golang.org/grpc/cmd/[email protected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
This directory contains scripts for building a docker image capable of compiling the EigenDA protobufs. I found | ||
it difficult to control the exact build version of the protobufs, since the version depends on whatever is installed | ||
locally when they are built. This is an attempt to standardize the protobuf build process. | ||
|
||
# Usage | ||
|
||
To build the docker image, run the following command: | ||
|
||
```bash | ||
./api/builder/build-docker.sh | ||
``` | ||
|
||
Once the docker image is built, you can build the protobufs via the following command: | ||
|
||
```bash | ||
./api/builder/build-protobufs.sh | ||
``` | ||
|
||
# Caveats | ||
|
||
I've tested this on my m3 macbook. It's possible that the docker image may have trouble on other architectures. | ||
Please report any issues you encounter with this build process to the EigenDA team. The goal is to be arcihtecturally | ||
agnostic, but that isn't a priority in the very short term. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The location where this script can be found. | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
# Add the --no-cache flag to force a rebuild. | ||
# Add the --progress=plain flag to show verbose output during the build. | ||
|
||
docker build \ | ||
-f "${SCRIPT_DIR}/Dockerfile" \ | ||
--tag pbuf-compiler:latest \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The location where this script can be found. | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
ROOT="${SCRIPT_DIR}/../.." | ||
|
||
docker container run \ | ||
--rm \ | ||
--mount "type=bind,source=${ROOT},target=/home/user/eigenda" \ | ||
pbuf-compiler bash -c 'source ~/.bashrc && cd eigenda && make protoc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Cleans the docker image and all cached steps. | ||
docker image rm pbuf-compiler 2> /dev/null || true | ||
docker builder prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is a handy little script for debugging the docker container. Attaches a bash shell to the container. | ||
|
||
# The location where this script can be found. | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
ROOT="${SCRIPT_DIR}/../.." | ||
|
||
docker container run \ | ||
--rm \ | ||
--mount "type=bind,source=${ROOT},target=/home/user/eigenda" \ | ||
-it \ | ||
pbuf-compiler bash | ||
|