From cb27d888d415a2ff3672f8f0cad024cd548731f4 Mon Sep 17 00:00:00 2001 From: James Walker Date: Tue, 10 Dec 2024 18:32:49 -0500 Subject: [PATCH] docker + log fixes --- .local.dev | 5 ++-- docker/bacalhau/Dockerfile | 4 ++-- docker/docker-compose.base.yml | 28 ++-------------------- docker/docker-compose.dev.yml | 3 +-- docker/docker-compose.yml | 25 ++------------------ docker/resource-provider/Dockerfile | 16 ++++++------- go.mod | 2 +- pkg/options/bacalhau.go | 4 ++-- pkg/system/log.go | 2 ++ stack | 36 ----------------------------- test/integration_test.go | 2 +- 11 files changed, 24 insertions(+), 103 deletions(-) diff --git a/.local.dev b/.local.dev index 387cf7f0..a6462b61 100644 --- a/.local.dev +++ b/.local.dev @@ -6,7 +6,8 @@ # posting your private keys in your commits/PRs. Unless you have a very good reason to do so, # leave the `.local.dev` file unchanged. -API_HOST=http://localhost:8002/ +# API_HOST=http://localhost:8002/ +API_HOST="" WEB3_RPC_URL=ws://localhost:8548 SERVER_PORT=8081 SERVER_URL=http://localhost:8081 @@ -28,6 +29,6 @@ WEB3_STORAGE_ADDRESS_=0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e WEB3_TOKEN_ADDRESS_=0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 WEB3_USERS_ADDRESS=0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 BACALHAU_API_HOST=localhost -BACALHAU_API_PORT=20000 +BACALHAU_API_PORT=1234 JOB_STATUS_POLL_INTERVAL=5 diff --git a/docker/bacalhau/Dockerfile b/docker/bacalhau/Dockerfile index e9d0869b..fdb92ef6 100644 --- a/docker/bacalhau/Dockerfile +++ b/docker/bacalhau/Dockerfile @@ -17,8 +17,8 @@ RUN mkdir -pm755 /etc/apt/keyrings && curl -o /etc/apt/keyrings/docker.asc -fsSL RUN nvidia-ctk runtime configure --runtime=docker --set-as-default # Install Bacalhau -ADD https://github.com/bacalhau-project/bacalhau/releases/download/v1.3.2/bacalhau_v1.3.2_linux_amd64.tar.gz . -RUN tar xfv bacalhau_v1.3.2_linux_amd64.tar.gz +ADD https://github.com/bacalhau-project/bacalhau/releases/download/v1.5.1/bacalhau_v1.5.1_linux_amd64.tar.gz . +RUN tar xfv bacalhau_v1.5.1_linux_amd64.tar.gz RUN mv bacalhau /usr/local/bin ADD https://raw.githubusercontent.com/moby/moby/refs/heads/master/hack/dind /usr/local/bin/dind diff --git a/docker/docker-compose.base.yml b/docker/docker-compose.base.yml index b70dee39..368946a7 100644 --- a/docker/docker-compose.base.yml +++ b/docker/docker-compose.base.yml @@ -48,23 +48,11 @@ services: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=solver-db - ipfs: - image: ipfs/kubo:v0.32.1 - container_name: ipfs - restart: unless-stopped - ports: - - 127.0.0.1:5001:5001 - - 127.0.0.1:8080:8080 - volumes: - - ipfs-data:/data/ipfs bacalhau: image: ghcr.io/lilypad-tech/bacalhau container_name: bacalhau restart: unless-stopped privileged: true - depends_on: - ipfs: - condition: service_healthy build: context: .. dockerfile: ./docker/bacalhau/Dockerfile @@ -74,21 +62,9 @@ services: - BACALHAU_ENVIRONMENT=local ports: - 1234:1234 - command: - [ - "bacalhau", - "serve", - "--node-type", - "compute,requester", - "--peer", - "none", - "--private-internal-ipfs=false", - "--job-selection-accept-networked", - "--ipfs-connect", - "/dns4/ipfs/tcp/5001", - ] + command: ["bacalhau", "serve", "--orchestrator", "--compute"] volumes: - - bacalhau-data:/root/.bacalhau + - ${HOME}/.bacalhau:/root/.bacalhau volumes: chain-data: ipfs-data: diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 2a6c1432..4ed9160a 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -50,8 +50,6 @@ services: container_name: resource-provider restart: unless-stopped depends_on: - ipfs: - condition: service_healthy solver: condition: service_healthy bacalhau: @@ -68,6 +66,7 @@ services: - "localhost:host-gateway" volumes: - lilypad-data:/tmp/lilypad/data + - ${HOME}/.bacalhau:/root/.bacalhau environment: - WEB3_PRIVATE_KEY=${RESOURCE_PROVIDER_PRIVATE_KEY} - IPFS_CONNECT=/dns4/ipfs/tcp/5001 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0923e5c2..1a26495d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,15 +1,5 @@ # This is a docker-compose file for use by Resource Providers services: - ipfs: - image: ipfs/kubo:v0.32.1 - container_name: ipfs - restart: unless-stopped - ports: - - 4001:4001 - - 127.0.0.1:5001:5001 - - 127.0.0.1:8080:8080 - volumes: - - ipfs-data:/data/ipfs bacalhau: image: ghcr.io/lilypad-tech/bacalhau container_name: bacalhau @@ -23,19 +13,7 @@ services: dockerfile: ./docker/bacalhau/Dockerfile environment: - BACALHAU_ENVIRONMENT=local - command: - [ - "bacalhau", - "serve", - "--node-type", - "compute,requester", - "--peer", - "none", - "--private-internal-ipfs=false", - "--job-selection-accept-networked", - "--ipfs-connect", - "/dns4/ipfs/tcp/5001", - ] + command: ["bacalhau", "serve", "--orchestrator", "--compute"] volumes: - bacalhau-data:/root/.bacalhau resource-provider: @@ -51,6 +29,7 @@ services: - COMPUTE_MODE=gpu volumes: - lilypad-data:/tmp/lilypad/data + - bacalhau-data:/root/.bacalhau environment: - WEB3_PRIVATE_KEY - WEB3_RPC_URL diff --git a/docker/resource-provider/Dockerfile b/docker/resource-provider/Dockerfile index ee04be1c..a5cad862 100644 --- a/docker/resource-provider/Dockerfile +++ b/docker/resource-provider/Dockerfile @@ -1,6 +1,6 @@ ARG COMPUTE_MODE=gpu -FROM golang:1.22.4 AS base +FROM golang:latest AS base WORKDIR /usr/src/app ARG NETWORK=testnet ARG VERSION @@ -34,11 +34,11 @@ RUN mv lilypad /usr/local/bin RUN apt update && apt install -y wget bash curl && apt clean # Install Bacalhau -RUN cd /tmp && \ - wget https://github.com/bacalhau-project/bacalhau/releases/download/v1.3.2/bacalhau_v1.3.2_linux_amd64.tar.gz && \ - tar xfv bacalhau_v1.3.2_linux_amd64.tar.gz && \ - mv bacalhau /usr/local/bin/bacalhau && \ - rm bacalhau_v1.3.2_linux_amd64.tar.gz +# RUN cd /tmp && \ +# wget https://github.com/bacalhau-project/bacalhau/releases/download/v1.3.2/bacalhau_v1.3.2_linux_amd64.tar.gz && \ +# tar xfv bacalhau_v1.3.2_linux_amd64.tar.gz && \ +# mv bacalhau /usr/local/bin/bacalhau && \ +# rm bacalhau_v1.3.2_linux_amd64.tar.gz # Add both lilypad and bacalhau executables to PATH ENV PATH="/usr/local/bin:${PATH}" @@ -48,8 +48,8 @@ RUN touch run RUN echo "#!/bin/bash" >> run # Ensure bacalhau is initialized -RUN echo "export BACALHAU_ENVIRONMENT=local" >> run -RUN echo "bacalhau id" >> run +# RUN echo "export BACALHAU_ENVIRONMENT=local" >> run +# RUN echo "bacalhau id" >> run # Launch Lilypad RUN echo "/usr/local/bin/lilypad resource-provider --network ${NETWORK} --disable-pow=${DISABLE_POW} --disable-telemetry=${DISABLE_TELEMETRY} &" >> run diff --git a/go.mod b/go.mod index edde141f..5ee4fe6c 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/lilypad-tech/lilypad go 1.23 -toolchain go1.23.2 +toolchain go1.23.3 require ( github.com/BurntSushi/toml v0.3.1 diff --git a/pkg/options/bacalhau.go b/pkg/options/bacalhau.go index 190e0e41..b2d023f4 100644 --- a/pkg/options/bacalhau.go +++ b/pkg/options/bacalhau.go @@ -9,8 +9,8 @@ import ( func GetDefaultBacalhauOptions() bacalhau.BacalhauExecutorOptions { return bacalhau.BacalhauExecutorOptions{ - ApiHost: GetDefaultServeOptionString("BACALHAU_API_HOST", "localhost"), - ApiPort: GetDefaultServeOptionString("BACALHAU_API_PORT", "20000"), + ApiHost: GetDefaultServeOptionString("BACALHAU_API_HOST", "localhost"), + ApiPort: GetDefaultServeOptionString("BACALHAU_API_PORT", "1234"), JobStatusPollInterval: GetDefaultServeOptionUint64("JOB_STATUS_POLL_INTERVAL", 5), } } diff --git a/pkg/system/log.go b/pkg/system/log.go index 742f84c0..4583f258 100644 --- a/pkg/system/log.go +++ b/pkg/system/log.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "time" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) @@ -49,6 +50,7 @@ func SetupLogging() { logLevel = parsedLogLevel } zerolog.CallerSkipFrameCount = 3 // Skip 3 frames (this function, log.Output, log.Logger) + zerolog.SetGlobalLevel(logLevel) log.Logger = log.Output(output).With().Caller().Logger().Level(logLevel) } diff --git a/stack b/stack index 28238282..a769b8eb 100755 --- a/stack +++ b/stack @@ -305,42 +305,6 @@ function integration-tests() { go test -v -tags="integration" -count 1 ./... } -############################################################################ -# run -# -# Note: The presence of the WEB3_PRIVATE_KEY here is only necessary for local development. You are advised not to import this key into a wallet nor use it for anything other for testing Lilypad locally -############################################################################ -function dev1(){ - export DISABLE_TELEMETRY=true - chain-clean - echo "========CHAIN CLEANED========" - clear - echo "========CHAIN========" - chain -} - -function dev2(){ - export DISABLE_TELEMETRY=true - echo "========BOOTING UP CHAIN========" - chain-boot - echo "========CHAIN BOOTED========" - clear - echo "========SOLVER========" - solver -} -function dev3(){ - export DISABLE_TELEMETRY=true - echo "========BACALHAU EXECUTOR========" - bacalhau-node -} - -function dev4(){ - export DISABLE_TELEMETRY=true - echo "========RESOURCE PROVIDER========" - resource-provider -} - - ############################################################################ # run # diff --git a/test/integration_test.go b/test/integration_test.go index 86620adc..052ebbae 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -122,7 +122,7 @@ func TestNoModeration(t *testing.T) { }) assert.NoError(t, err, "there was an error running the job") - assert.Equal(t, "QmbCi3yoKzckff24rUJML1ZesVb35cd2LUNMiMYksEGkWv", result.Result.DataID, "the data ID was correct") + assert.Equal(t, "bafkreie2v6u2wyd6p7ke4itufngshkmgzppwulakfvrmkb5bibcqk5qjgy", result.Result.DataID, "the data ID was correct") localPath := solver.GetDownloadsFilePath(result.Result.DealID) fmt.Printf("local path: %s\n", localPath)