mirror of
https://github.com/metal3d/docker-xmrig.git
synced 2024-09-11 13:15:29 +03:00
Change version, use ubuntu to activage CUDA
- using CUDA is possible using the xmrig-cuda plugin - it needs, of course, to configure docker or podman to be able to share the GPU - we now have more options to deactivate CPU, force CUDA, etc. - this change the size of the image, a lot...
This commit is contained in:
parent
c2a4dffa83
commit
ae06d03bcf
89
Dockerfile
89
Dockerfile
@ -1,34 +1,81 @@
|
||||
FROM alpine
|
||||
|
||||
FROM ubuntu:22.04 as builder
|
||||
LABEL maintainer="Patrice Ferlet <metal3d@gmail.com>"
|
||||
|
||||
ARG VERSION=6.19.3
|
||||
|
||||
RUN set -xe;\
|
||||
echo "@community http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories; \
|
||||
apk update; \
|
||||
apk add util-linux build-base cmake libuv-static libuv-dev openssl-dev hwloc-dev@community; \
|
||||
wget https://github.com/xmrig/xmrig/archive/v${VERSION}.tar.gz; \
|
||||
ARG CUDA_VERSION=11-4
|
||||
RUN set -xe; \
|
||||
apt update; \
|
||||
apt install -y nvidia-cuda-toolkit;
|
||||
|
||||
ARG CUDA_PLUGIN_VERSION=6.17.0
|
||||
RUN set -xe; \
|
||||
apt install -y wget build-essential cmake automake libtool autoconf; \
|
||||
apt install -y gcc-9 g++-9; \
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
|
||||
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
|
||||
wget https://github.com/xmrig/xmrig-cuda/archive/refs/tags/v${CUDA_PLUGIN_VERSION}.tar.gz; \
|
||||
tar xf v${CUDA_PLUGIN_VERSION}.tar.gz; \
|
||||
cd xmrig-cuda-${CUDA_PLUGIN_VERSION}; \
|
||||
mkdir build; \
|
||||
cd build; \
|
||||
cmake .. -DCUDA_LIB=/usr/lib/x86_64-linux-gnu/stubs/libcuda.so -DCUDA_TOOLKIT_ROOT_DIR=/usr/lib/x86_64-linux-gnu -DCUDA_ARCH="75;80"; \
|
||||
make -j $(nproc);
|
||||
|
||||
|
||||
FROM ubuntu:22.04 as build-runner
|
||||
ARG VERSION=6.20.0
|
||||
LABEL maintainer="Patrice Ferlet <metal3d@gmail.com>"
|
||||
|
||||
RUN set -xe; \
|
||||
apt update; \
|
||||
#apt -y install wget jq git build-essential cmake automake libtool autoconf; \
|
||||
apt install -y wget build-essential cmake automake libtool autoconf; \
|
||||
apt install -y gcc-9 g++-9; \
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
|
||||
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
wget https://github.com/xmrig/xmrig/archive/refs/tags/v${VERSION}.tar.gz; \
|
||||
tar xf v${VERSION}.tar.gz; \
|
||||
mkdir -p xmrig-${VERSION}/build; \
|
||||
cd xmrig-${VERSION}/build; \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DUV_LIBRARY=/usr/lib/libuv.a;\
|
||||
make -j $(nproc); \
|
||||
cp xmrig /usr/local/bin/xmrig;\
|
||||
rm -rf xmrig* *.tar.gz; \
|
||||
apk del build-base; \
|
||||
apk del openssl-dev;\
|
||||
apk del hwloc-dev; \
|
||||
apk del cmake; \
|
||||
apk add hwloc@community;
|
||||
mv xmrig-${VERSION} /xmrig; \
|
||||
cd /xmrig; \
|
||||
mkdir build; \
|
||||
cd scripts; \
|
||||
./build_deps.sh; \
|
||||
cd ../build; \
|
||||
cmake .. -DXMRIG_DEPS=scripts/deps; \
|
||||
make -j $(nproc);
|
||||
RUN set -xe; \
|
||||
cd /xmrig; \
|
||||
cp build/xmrig /xmrig
|
||||
|
||||
|
||||
FROM ubuntu:22.04 as runner
|
||||
ARG CUDA_PLUGIN_VERSION=6.17.0
|
||||
LABEL maintainer="Patrice Ferlet <metal3d@gmail.com>"
|
||||
RUN set -xe; \
|
||||
mkdir /xmrig; \
|
||||
apt update; \
|
||||
apt -y install jq; \
|
||||
apt -y install libnvidia-compute-535 libnvrtc11.2; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=build-runner /xmrig/xmrig /xmrig/xmrig
|
||||
COPY --from=build-runner /xmrig/src/config.json /xmrig/config.json
|
||||
COPY --from=builder /xmrig-cuda-${CUDA_PLUGIN_VERSION}/build/libxmrig-cuda.so /usr/lib64/
|
||||
|
||||
|
||||
ENV POOL_USER="44vjAVKLTFc7jxTv5ij1ifCv2YCFe3bpTgcRyR6uKg84iyFhrCesstmWNUppRCrxCsMorTP8QKxMrD3QfgQ41zsqMgPaXY5" \
|
||||
POOL_PASS="" \
|
||||
POOL_URL="xmr.metal3d.org:8080" \
|
||||
DONATE_LEVEL=5 \
|
||||
PRIORITY=0 \
|
||||
THREADS=0
|
||||
THREADS=0 \
|
||||
PATH="/xmrig:${PATH}" \
|
||||
CUDA=false \
|
||||
CUDA_BF="" \
|
||||
ALGO="" \
|
||||
COIN=""
|
||||
|
||||
|
||||
WORKDIR /xmrig
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
WORKDIR /tmp
|
||||
EXPOSE 3000
|
||||
|
20
Makefile
20
Makefile
@ -1,4 +1,6 @@
|
||||
VERSION = 6.19.3
|
||||
VERSION = 6.20.0
|
||||
CUDA_PLUGIN_VERSION=6.17.0
|
||||
CUDA_VERSION=11-4
|
||||
REL = $(VERSION)-1
|
||||
THREADS = $(shell nproc)
|
||||
PRIORITY = 0
|
||||
@ -13,9 +15,23 @@ build:
|
||||
$(CC) build -t $(REPO):$(REL) --build-arg VERSION=$(VERSION) .
|
||||
$(CC) tag $(REPO):$(REL) $(REPO):latest
|
||||
|
||||
run:
|
||||
run: build
|
||||
$(CC) run --rm -it -e THREADS=$(THREADS) -e PRIORITY=$(PRIORITY) $(REPO):$(REL)
|
||||
|
||||
run-cuda: build
|
||||
$(CC) run \
|
||||
--device nvidia.com/gpu=all \
|
||||
--device /dev/cpu \
|
||||
--device /dev/cpu_dma_latency \
|
||||
--security-opt=label=disable \
|
||||
--rm -it \
|
||||
--cap-add=ALL \
|
||||
--privileged \
|
||||
-e THREADS=$(THREADS) \
|
||||
-e PRIORITY=$(PRIORITY) \
|
||||
-e CUDA=true \
|
||||
-e NO_CPU=true \
|
||||
$(REPO):$(REL)
|
||||
|
||||
deploy: build
|
||||
$(CC) push $(REPO):$(REL)
|
||||
|
@ -1,6 +1,15 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
metal3d_wallet="44vjAVKLTFc7jxTv5ij1ifCv2YCFe3bpTgcRyR6uKg84iyFhrCesstmWNUppRCrxCsMorTP8QKxMrD3QfgQ41zsqMgPaXY5"
|
||||
cd /xmrig
|
||||
|
||||
function uuidgen() {
|
||||
if [ -x "$(command -v uuidgen)" ]; then
|
||||
uuidgen
|
||||
else
|
||||
cat /proc/sys/kernel/random/uuid
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$POOL_USER" == ${metal3d_wallet} ]; then
|
||||
# here, there is two cases:
|
||||
@ -60,14 +69,33 @@ if [ "$PRIORITY" -ge 0 ] && [ "$PRIORITY" -le 5 ]; then
|
||||
CPU_PRIORITY=$PRIORITY
|
||||
fi
|
||||
|
||||
# for others parameters
|
||||
OTHERS_OPTS=""
|
||||
if [ "$COIN" != "" ]; then
|
||||
|
||||
if [ "$ALGO" != "" ] && [ "$COIN" == "" ] ; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --algo=$ALGO"
|
||||
elif [ "$COIN" != "" ]; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --coin=$COIN"
|
||||
fi
|
||||
|
||||
if [ "$ALGO" != "" ]; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --algo=$ALGO"
|
||||
if [ "$CUDA_BF" != "" ]; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --cuda-bfactor=$CUDA_BF"
|
||||
fi
|
||||
|
||||
if [ "${NO_CPU}" == "true" ]; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --no-cpu"
|
||||
fi
|
||||
|
||||
cat config.json
|
||||
|
||||
if [ "${CUDA}" == "true" ]; then
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --cuda"
|
||||
jq '.cuda.enabled = true' config.json > config.json.tmp && mv config.json.tmp config.json
|
||||
jq '.cpu.enabled = false' config.json > config.json.tmp && mv config.json.tmp config.json
|
||||
fi
|
||||
|
||||
if [ "${OPENCL}" == "true" ]; then
|
||||
apt update && apt install -y nvidia-opencl-dev
|
||||
jq '.opencl.enabled = true' config.json > config.json.tmp && mv config.json.tmp config.json
|
||||
OTHERS_OPTS=$OTHERS_OPTS" --opencl"
|
||||
fi
|
||||
|
||||
exec xmrig --user=${POOL_USER} --url=${POOL_URL} ${PASS_OPTS} ${THREAD_OPTS} \
|
||||
@ -75,4 +103,5 @@ exec xmrig --user=${POOL_USER} --url=${POOL_URL} ${PASS_OPTS} ${THREAD_OPTS} \
|
||||
--donate-level=$DONATE_LEVEL \
|
||||
--http-port=3000 --http-host=0.0.0.0 --http-enabled \
|
||||
--http-access-token=${ACCESS_TOKEN} \
|
||||
--nicehash \
|
||||
${OTHERS_OPTS}
|
||||
|
Loading…
Reference in New Issue
Block a user