Skip to content

Commit

Permalink
build: docker releases and compose file (#234)
Browse files Browse the repository at this point in the history
* build: docker releases and compose file

* fix: use docker.sock

* fix: pr feedback

* fix: pr feedback

* Update .github/workflows/release_docker.yml

Co-authored-by: Brian Ginsburg <[email protected]>

* fix: bacalhau data mount

---------

Co-authored-by: Brian Ginsburg <[email protected]>
  • Loading branch information
walkah and bgins authored Jul 11, 2024
1 parent 83ee29b commit c43a71c
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 32 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ jobs:
docker:
name: Push Docker image
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: ghcr.io/Lilypad-Tech/bacalhau
dockerfile: ./docker/bacalhau/Dockerfile
- image: ghcr.io/Lilypad-Tech/job-creator
dockerfile: ./docker/job-creator/Dockerfile
- image: ghcr.io/Lilypad-Tech/resource-provider
dockerfile: ./docker/resource-provider/Dockerfile
- image: ghcr.io/Lilypad-Tech/solver
dockerfile: ./docker/solver/Dockerfile
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -24,12 +35,12 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/Lilypad-Tech/resource-provider
images: ${{ matrix.image }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/resource-provider/Dockerfile
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ops/testnet/.terraform/providers
.run/
bin/
vendor/
./data/
/data/
.DS_Store
11 changes: 11 additions & 0 deletions docker/bacalhau/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM docker:dind AS base

RUN apk update
RUN apk add wget
RUN apk add bash

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
RUN mv bacalhau /usr/local/bin

ENTRYPOINT [ "bacalhau" ]
42 changes: 21 additions & 21 deletions docker/chain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ RUN echo "done" >> run
RUN echo "docker pull offchainlabs/nitro-node:v2.3.4-b4cc111 " >> run

RUN echo "docker run -d --name devnet -p 0.0.0.0:8547:8547 -p 0.0.0.0:8548:8548 offchainlabs/nitro-node:v2.3.4-b4cc111 "\
" --init.dev-init " \
" --init.dev-init-address $admin_address "\
" --node.dangerous.no-l1-listener "\
" --node.parent-chain-reader.enable=false "\
" --parent-chain.id=1337 "\
" --chain.id=412346 "\
" --persistent.chain /tmp/dev-test "\
" --node.sequencer "\
" --execution.sequencer.enable "\
" --node.dangerous.no-sequencer-coordinator "\
" --node.staker.enable=false "\
" --init.empty=false "\
" --http.port 8547 "\
" --http.addr 0.0.0.0 "\
" --ws.port 8548 "\
" --ws.addr 0.0.0.0 "\
" --http.corsdomain=* "\
" --http.vhosts=* "\
" --ws.origins=* "\
" " >> run
" --init.dev-init " \
" --init.dev-init-address $admin_address "\
" --node.dangerous.no-l1-listener "\
" --node.parent-chain-reader.enable=false "\
" --parent-chain.id=1337 "\
" --chain.id=412346 "\
" --persistent.chain /tmp/dev-test "\
" --node.sequencer "\
" --execution.sequencer.enable "\
" --node.dangerous.no-sequencer-coordinator "\
" --node.staker.enable=false "\
" --init.empty=false "\
" --http.port 8547 "\
" --http.addr 0.0.0.0 "\
" --ws.port 8548 "\
" --ws.addr 0.0.0.0 "\
" --http.corsdomain=* "\
" --http.vhosts=* "\
" --ws.origins=* "\
" " >> run

RUN echo "until wget -qO- http://0.0.0.0:8547 >/dev/null 2>&1; do " >> run
RUN echo " echo 'Waiting for Nitro to start...'" >> run
Expand Down Expand Up @@ -71,7 +71,7 @@ RUN chmod +x cloudflared-linux-amd64

FROM base AS expose-local

FROM expose-$expose_via AS FINAL
FROM expose-$expose_via AS final
RUN chmod +x run
RUN echo "wait -n" >> run
ENTRYPOINT ["bash", "./run"]
97 changes: 97 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: lilypad
services:
chain:
image: offchainlabs/nitro-node:v2.3.4-b4cc111
container_name: chain
ports:
- 8547:8547
- 8548:8548
command:
[
"--init.dev-init",
"--init.dev-init-address",
$ADMIN_ADDRESS,
"--node.dangerous.no-l1-listener",
"--node.parent-chain-reader.enable=false",
"--parent-chain.id=1337",
"--chain.id=412346",
"--node.sequencer",
"--execution.sequencer.enable",
"--node.dangerous.no-sequencer-coordinator",
"--node.staker.enable=false",
"--init.empty=false",
"--http.port",
"8547",
"--http.addr",
"0.0.0.0",
"--ws.port",
"8548",
"--ws.addr",
"0.0.0.0",
]
volumes:
- ../data/chain:/home/user/.arbitrum
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8548/"]
interval: 30s
timeout: 10s
retries: 5
solver:
image: ghcr.io/lilypad-tech/solver
container_name: solver
depends_on:
- chain
build:
context: ..
dockerfile: ./docker/solver/Dockerfile
args:
- network=dev
extra_hosts:
- "localhost:host-gateway"
environment:
- DOPPLER_TOKEN=${DOPPLER_TOKEN_SOLVER}
ports:
- 8080:8080
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 5

job-creator:
image: ghcr.io/lilypad-tech/job-creator
container_name: job-creator
restart: unless-stopped
depends_on:
- chain
- solver
build:
context: ..
dockerfile: ./docker/job-creator/Dockerfile
args:
- network=dev
extra_hosts:
- "localhost:host-gateway"
environment:
- DOPPLER_TOKEN=${DOPPLER_TOKEN_JOB_CREATOR}
resource-provider:
image: ghcr.io/lilypad-tech/resource-provider
container_name: resource-provider
restart: unless-stopped
depends_on:
- chain
- solver
build:
context: ..
dockerfile: ./docker/resource-provider/Dockerfile
args:
- NETWORK=dev
extra_hosts:
- "localhost:host-gateway"
volumes:
- ../data/bacalhau:/tmp/lilypad/data
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WEB3_PRIVATE_KEY
- BACALHAU_SERVE_IPFS_PATH=/tmp/lilypad/data/ipfs
- LOG_LEVEL=debug
2 changes: 1 addition & 1 deletion docker/job-creator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:latest as base
FROM golang:latest AS base
WORKDIR /usr/src/app

ARG network=dev
Expand Down
4 changes: 0 additions & 4 deletions docker/resource-provider/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ ENV PATH="/usr/local/bin:${PATH}"
# Create a startup script to run both services simultaneously
RUN touch run
RUN echo "#!/bin/bash" >> run
# Launch docker daemon
RUN echo "dockerd &" >> run
RUN echo "while ! docker -v; do sleep 1; done" >> run
RUN echo "sleep 3" >> run
# Launch Bacalhau
RUN echo "/usr/local/bin/bacalhau serve --node-type compute,requester --peer none --private-internal-ipfs=false --job-selection-accept-networked &" >> run
# Launch Lilypad
Expand Down
4 changes: 2 additions & 2 deletions docker/solver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG expose_via=local

FROM golang:latest as base
FROM golang:latest AS base
WORKDIR /usr/src/app

ARG arch=amd64
Expand All @@ -25,7 +25,7 @@ FROM base AS expose-local
EXPOSE 8080
RUN echo "doppler run -- lilypad solver --network $network" >> run

FROM expose-$expose_via AS FINAL
FROM expose-$expose_via AS final
RUN chmod +x run

CMD ["/bin/bash", "./run"]
35 changes: 34 additions & 1 deletion stack
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OS_ARCH=$(uname -m | awk '{if ($0 ~ /arm64|aarch64/) print "arm64"; else if ($0 ~ /x86_64|amd64/) print "amd64"; else print "unsupported_arch"}')

############################################################################
# docker compose
############################################################################
function compose-env() {
export ADMIN_ADDRESS=${@:-"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"}
export DOPPLER_TOKEN_SOLVER="$(doppler configs tokens create -p solver -c dev docker --max-age 10m --plain)"
export DOPPLER_TOKEN_JOB_CREATOR="$(doppler configs tokens create -p job-creator -c dev docker --max-age 10m --plain)"
}

function compose-init() {
compose-env
chain-clean
docker compose -f ./docker/docker-compose.dev.yml up chain -d
chain-boot
}

function compose-build() {
compose-env
docker compose -f ./docker/docker-compose.dev.yml build "$@"
}

function compose-up() {
compose-env
doppler run -p resource-provider -c dev -- docker compose -f ./docker/docker-compose.dev.yml up "$@"
}

function compose-down() {
compose-env
docker compose -f ./docker/docker-compose.dev.yml down
}

############################################################################
# chain
############################################################################
Expand Down Expand Up @@ -51,6 +82,7 @@ function chain-boot() {
npx hardhat deploy --network dev
echo "- Fund services with tokens"
npx hardhat run scripts/fund-services-tokens.ts --network dev
cd ..
echo "- Done"
}

Expand Down Expand Up @@ -111,6 +143,7 @@ function go-binding() {
}

function chain-clean(){
rm -Rf $(pwd)/data/chain
rm -rf $(pwd)/hardhat/artifacts
rm -rf $(pwd)/hardhat/cache
rm -rf $(pwd)/hardhat/deployments/geth
Expand Down Expand Up @@ -222,10 +255,10 @@ function resource-provider-docker-build() {
function resource-provider-docker-run() {
docker run \
--rm \
--privileged \
--name resource-provider \
--add-host localhost:host-gateway \
--env-file <(doppler -p resource-provider -c dev secrets download --no-file --format docker) \
-v /var/run/docker.sock:/var/run/docker.sock \
-e OFFER_GPU=0 \
-e BACALHAU_API_HOST="DO_NOT_SET" \
resource-provider
Expand Down

0 comments on commit c43a71c

Please sign in to comment.