diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 28462a73..e8c968e9 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -86,6 +86,7 @@ services: dockerfile: ./docker/resource-provider/Dockerfile args: - NETWORK=dev + - COMPUTE_MODE=cpu extra_hosts: - "localhost:host-gateway" volumes: diff --git a/docker/resource-provider/Dockerfile b/docker/resource-provider/Dockerfile index a7293cb4..191d9a76 100644 --- a/docker/resource-provider/Dockerfile +++ b/docker/resource-provider/Dockerfile @@ -1,20 +1,16 @@ -FROM docker:dind -WORKDIR /usr/src/app +ARG COMPUTE_MODE=gpu -# Build args +FROM nvidia/cuda:12.0.1-cudnn8-devel-ubuntu22.04 AS base +WORKDIR /usr/src/app ARG NETWORK=testnet -ARG DISABLE_POW=false # Default environment variables ENV LOG_LEVEL=info -ENV OFFER_GPU=1 ENV BACALHAU_API_HOST="localhost" ENV WEB3_PRIVATE_KEY="" # Install necessary dependencies -RUN apk update -RUN apk add wget -RUN apk add bash +RUN apt update && apt install -y wget bash && apt clean # Install Bacalhau RUN cd /tmp && \ @@ -28,7 +24,17 @@ COPY --from=golang:1.22.4-alpine /usr/local/go/ /usr/local/go/ ENV PATH="/usr/local/go/bin:${PATH}" COPY . . -RUN go build -v . + +FROM base AS build-gpu +RUN nvcc --version && nvcc --ptx -o ./pkg/resourceprovider/cudaminer/keccak.ptx ./pkg/resourceprovider/cudaminer/keccak.cu +RUN go build -v --tags cuda +ENV DISABLE_POW=false + +FROM base AS build-cpu +RUN go build -v +ENV DISABLE_POW=true + +FROM build-$COMPUTE_MODE AS final RUN mv lilypad /usr/local/bin # Add both lilypad and bacalhau executables to PATH