Skip to content

Commit

Permalink
Add docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbrucker committed Mar 24, 2024
1 parent 3341ced commit b622f61
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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: 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
31 changes: 31 additions & 0 deletions harvester-docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
7 changes: 7 additions & 0 deletions harvester-docker-start.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit b622f61

Please sign in to comment.