forked from Layr-Labs/eigenda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Cody Littley <[email protected]>
- Loading branch information
1 parent
e839473
commit 6a831eb
Showing
10 changed files
with
150 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 |
---|---|---|
|
@@ -10,4 +10,7 @@ coverage.* | |
|
||
contracts/broadcast | ||
|
||
lightnode/docker/build-info.txt | ||
lightnode/docker/args.sh | ||
|
||
.idea |
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 @@ | ||
SHELL := /bin/bash | ||
|
||
# Clean the light node build files. | ||
clean: | ||
rm -rf ./bin | ||
|
||
# Build the light node. | ||
build: clean | ||
go mod tidy | ||
go build -o ./bin/lnode ./main | ||
|
||
# Run the light node. | ||
run: build | ||
./bin/lnode | ||
|
||
# Delete the docker images for the light node. | ||
clean-docker: | ||
./docker/clean.sh | ||
|
||
# Build the docker images for the light node. | ||
build-docker: | ||
./docker/build.sh | ||
|
||
# Run the docker image for the light node. | ||
run-docker: | ||
./docker/run.sh | ||
|
||
# Open an interactive bash shell inside the light node docker container. Useful for debugging issues with the image. | ||
debug-docker: | ||
./docker/debug.sh |
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,48 @@ | ||
FROM golang:1.21.12-bookworm AS base | ||
|
||
# Install core dependencies | ||
RUN apt update | ||
RUN apt install -y build-essential | ||
|
||
# Set up lnode user | ||
RUN useradd -m -s /bin/bash lnode | ||
USER lnode | ||
WORKDIR /home/lnode | ||
# Remove default crud | ||
RUN rm .bashrc | ||
RUN rm .bash_logout | ||
RUN rm .profile | ||
|
||
# Copy go.mod and download dependencies without copying the entire repository. | ||
# Prevents us from downloading dependencies every time we make a change to the repository. | ||
RUN mkdir -p /home/lnode/eigenda | ||
COPY --chown=lnode go.mod /home/lnode/eigenda/go.mod | ||
COPY --chown=lnode go.sum /home/lnode/eigenda/go.sum | ||
WORKDIR /home/lnode/eigenda | ||
RUN go mod download | ||
|
||
# Copy the remainder of the eigenda repository | ||
COPY --chown=lnode . /home/lnode/eigenda | ||
|
||
# Download all go dependencies and build the binary. | ||
WORKDIR /home/lnode/eigenda/lightnode | ||
RUN make build | ||
|
||
# In order to equip this image with a shell for debugging, | ||
# swap out the "FROM scratch" below with "FROM golang:1.21.12-bookworm" | ||
FROM scratch AS final | ||
|
||
# Copy over files needed for lnode user. | ||
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo | ||
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=base /etc/passwd /etc/passwd | ||
COPY --from=base /etc/group /etc/group | ||
|
||
USER lnode | ||
WORKDIR /home/lnode | ||
|
||
# Copy the executable binary. | ||
COPY --from=base /home/lnode/eigenda/lightnode/bin/lnode /home/lnode/lnode | ||
|
||
# Run the light node when the container starts. | ||
CMD ["/home/lnode/lnode"] |
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,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The location where this script can be found. | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd "${SCRIPT_DIR}" | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
cd "${REPO_ROOT}" | ||
|
||
docker build \ | ||
--build-arg="REPO_ROOT=${REPO_ROOT}" \ | ||
-f "lightnode/docker/Dockerfile" \ | ||
--tag lnode: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,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Cleans the docker image and all cached steps. | ||
docker image rm lnode 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,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Starts the container with an interactive bash shell. This is useful for debugging the container. | ||
|
||
# Do setup for the data directory. This is a directory where data that needs | ||
# to persist in-between container runs is stored. | ||
source ./docker/setup-data-dir.sh | ||
|
||
docker container run \ | ||
--mount "type=bind,source=${DATA_PATH},target=/home/lnode/data" \ | ||
--rm \ | ||
-it \ | ||
lnode bash |
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 @@ | ||
# Default arguments for building the docker image. | ||
# To override these values locally, create a file named `args.sh` in the same directory. 'args.sh' is ignored by git. | ||
|
||
# The location on the host file system where light node data will be stored. | ||
export DATA_PATH=~/.lnode-data |
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 | ||
|
||
# Starts the container and runs the light node. | ||
|
||
# Do setup for the data directory. This is a directory where data that needs | ||
# to persist in-between container runs is stored. | ||
source ./docker/setup-data-dir.sh | ||
|
||
docker run \ | ||
--rm \ | ||
--mount "type=bind,source=${DATA_PATH},target=/home/lnode/data" \ | ||
lnode |
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,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Sets up the data directory for the light node container. | ||
|
||
# Default arguments. | ||
source docker/default-args.sh | ||
# Local overrides for arguments. | ||
source docker/args.sh | ||
|
||
# Create the data directory if it doesn't exist. | ||
mkdir -p $DATA_PATH | ||
|
||
echo "Using data directory $DATA_PATH" |
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,8 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
// main is the entrypoint for the light node. | ||
func main() { | ||
fmt.Println("Hello world") | ||
} |