diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..b2636de --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,64 @@ +name: Docker + +on: + workflow_dispatch: + inputs: + tag: + description: "Release tag of upstream drplotter repo" + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + build-and-push-images: + name: Build and push images + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + strategy: + fail-fast: false + matrix: + include: + - final-build-stage: plotter + - final-build-stage: solver + - final-build-stage: server + - final-build-stage: harvester + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=true + suffix=-${{ matrix.final-build-stage }},onlatest=true + tags: | + type=raw,value=${{ inputs.tag }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to the container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + build-args: GITHUB_RELEASE_TAG=${{ inputs.tag }} + target: ${{ matrix.final-build-stage }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bcac784 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +FROM debian:12-slim AS builder +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y xz-utils curl +WORKDIR / +ARG GITHUB_RELEASE_TAG +RUN GITHUB_RELEASE_TAG=${GITHUB_RELEASE_TAG%-*} \ + && curl -L https://github.com/drnick23/drplotter/releases/download/${GITHUB_RELEASE_TAG}/drplotter-${GITHUB_RELEASE_TAG}-x86_64.tar.gz --output drplotter.tar.gz \ + && tar -xf drplotter.tar.gz \ + && mv drplotter-${GITHUB_RELEASE_TAG}-x86_64 drplotter + + +FROM mikefarah/yq:4 AS yq + + +FROM debian:12-slim AS base +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install --no-install-recommends -y \ + tzdata \ + && rm -rf /var/lib/apt/lists/* +WORKDIR /app + + +FROM base AS compute-base +RUN apt-get update && apt-get install --no-install-recommends -y \ + ocl-icd-libopencl1 \ + && rm -rf /var/lib/apt/lists/* +RUN mkdir -p /etc/OpenCL/vendors && \ + echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd +ENV NVIDIA_VISIBLE_DEVICES all +ENV NVIDIA_DRIVER_CAPABILITIES compute,utility + + +FROM compute-base AS plotter +COPY --from=builder /drplotter/drplotter . +ENTRYPOINT ["./drplotter"] + + +FROM compute-base AS solver +COPY --from=builder /drplotter/drsolver . +ENTRYPOINT ["./drsolver"] + + +FROM base AS server +COPY --from=builder /drplotter/drserver . +ENTRYPOINT ["./drserver"] + + +FROM base AS harvester +COPY --from=yq /usr/bin/yq /usr/bin/yq +COPY --from=builder /drplotter/drharvester . +COPY harvester-docker-entrypoint.sh ./docker-entrypoint.sh +COPY harvester-docker-start.sh ./docker-start.sh +ENV CHIA_ROOT="/root/.chia/mainnet" +ENTRYPOINT ["./docker-entrypoint.sh"] +CMD ["./docker-start.sh"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..132efaf --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,48 @@ +version: '3' +services: + plotter: + image: ghcr.io/foxypool/drplotter:latest-plotter + restart: unless-stopped + runtime: nvidia + volumes: + - /path/to/plots:/plots +# environment: +# ## GPU Specific Options +# NVIDIA_VISIBLE_DEVICES: 0,3 + command: plot -f -c -d /plots/ --compression + server: + image: ghcr.io/foxypool/drplotter:latest-server + restart: unless-stopped + ports: + - "8080:8080" + solver: + image: ghcr.io/foxypool/drplotter:latest-solver + restart: unless-stopped + runtime: nvidia +# environment: +# ## Remote drsolver +# DRPLOTTER_CLIENT_TOKEN: your_unique_48_character_token_here +# ## Local drserver +# DRSERVER_IP_ADDRESS: your_drserver_ip_address:port +# ## GPU Specific Options +# NVIDIA_VISIBLE_DEVICES: 0,3 + harvester: + image: ghcr.io/foxypool/drplotter:latest-harvester + restart: unless-stopped + volumes: + - /path/to/.chia:/root/.chia/mainnet + - /path/to/plots:/plots +# - /path/to/ssl/ca:/path/in/container + environment: + CHIA_LOG_LEVEL: 'INFO' + CHIA_PLOTS: /plots + CHIA_FARMER_ADDRESS: your_farmer_ip_or_hostname_here + CHIA_FARMER_PORT: 8447 +# CHIA_HOSTNAME: 127.0.0.1 +# TZ: 'UTC' +# ## Only set CHIA_CA once on init, remove afterward +# CHIA_CA: /path/in/container +# ## Remote drsolver +# DRPLOTTER_CLIENT_TOKEN: your_unique_48_character_token_here +# ## Local drserver +# DRSERVER_IP_ADDRESS: your_drserver_ip_address:port diff --git a/harvester-docker-entrypoint.sh b/harvester-docker-entrypoint.sh new file mode 100755 index 0000000..607ef8c --- /dev/null +++ b/harvester-docker-entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [[ -n "${TZ}" ]]; then + echo "Timezone set to ${TZ}" +fi + +./drchia init --fix-ssl-permissions + +if [[ -n ${CHIA_HOSTNAME} ]]; then + yq -i '.self_hostname = env(CHIA_HOSTNAME)' "$CHIA_ROOT/config/config.yaml" +else + yq -i '.self_hostname = "127.0.0.1"' "$CHIA_ROOT/config/config.yaml" +fi + +if [[ -n "${CHIA_LOG_LEVEL}" ]]; then + ./drchia configure --log-level "${CHIA_LOG_LEVEL}" +fi + +for p in ${CHIA_PLOTS//:/ }; do + mkdir -p "${p}" + if [[ ! $(ls -A "$p") ]]; then + echo "Plots directory '${p}' appears to be empty, try mounting a plot directory with the docker -v command" + fi + ./drchia plots add -d "${p}" +done + +if [[ -n ${CHIA_FARMER_ADDRESS} && -n ${CHIA_FARMER_PORT} && -n ${CHIA_CA} ]]; then + ./drchia init -c "${CHIA_CA}" && ./drchia configure --set-farmer-peer "${CHIA_FARMER_ADDRESS}:${CHIA_FARMER_PORT}" +fi + +exec "$@" diff --git a/harvester-docker-start.sh b/harvester-docker-start.sh new file mode 100755 index 0000000..bbd403d --- /dev/null +++ b/harvester-docker-start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +./drchia start harvester + +trap "echo Shutting down ...; ./drchia stop all -d; exit 0" SIGINT SIGTERM + +tail -F "$CHIA_ROOT/log/debug.log"