mirror of
https://github.com/ivuorinen/docker-xmrig.git
synced 2026-01-26 03:24:10 +00:00
Initial commit
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Unix-style newlines with a newline ending every file
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 120
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
134
.github/README.md
vendored
Normal file
134
.github/README.md
vendored
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
# My xmrig Miner
|
||||||
|
|
||||||
|
This is a simple miner that uses the xmrig miner to mine Monero.
|
||||||
|
|
||||||
|
The configuration is set to mine to my local p2pool node,
|
||||||
|
but you can change it to your own.
|
||||||
|
|
||||||
|
## What is XMRig?
|
||||||
|
|
||||||
|
[XMRig](https://xmrig.com/miner) is a high performance, open source, cross platform
|
||||||
|
RandomX, KawPow, CryptoNight and AstroBWT unified CPU/GPU miner
|
||||||
|
and RandomX benchmark. Official binaries are available for
|
||||||
|
Windows, Linux, macOS and FreeBSD.
|
||||||
|
|
||||||
|
## How to use this image
|
||||||
|
|
||||||
|
**Step 1:** Clone the GitHub repo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/ivuorinen/docker-xmrig.git
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 2:** Edit the `config.json` file after cloning it.
|
||||||
|
|
||||||
|
- Provide your pool configuration:
|
||||||
|
- url: your-p2pool-node:3333
|
||||||
|
- user: your-miner-identifier
|
||||||
|
- pass: ""
|
||||||
|
|
||||||
|
For all the available options,
|
||||||
|
visit [XMRig Config File](https://xmrig.com/docs/miner/config) documentation.
|
||||||
|
|
||||||
|
**Step 3:** Deploy the image as a standalone Docker container or
|
||||||
|
to a Kubernetes cluster.
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -dit --rm \
|
||||||
|
--volume "$(pwd)"/config.json:/xmrig/etc/config.json:ro \
|
||||||
|
--volume "$(pwd)"/log:/xmrig/log \
|
||||||
|
--name xmrig ivuorinen/docker-xmrig:latest \
|
||||||
|
/xmrig/xmrig --config=/xmrig/etc/config.json
|
||||||
|
```
|
||||||
|
|
||||||
|
If you prefer **Docker Compose**, edit the [`docker-compose.yml`][docker-compose.yml]
|
||||||
|
manifest as needed and run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Kubernetes
|
||||||
|
|
||||||
|
**Step 1:** Create a _namespace_ for our XMRig application (optional but recommended):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create ns xmrig
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 2:** Create a _configmap_ in the new namespace `xmrig`
|
||||||
|
from the [`config.json`][config.json] file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create configmap xmrig-config --from-file config.json -n xmrig
|
||||||
|
```
|
||||||
|
|
||||||
|
_remember to edit this file with your own pool configuration and wallet address
|
||||||
|
or it will mine against my anonymised docker wallet_
|
||||||
|
|
||||||
|
**Step 3:** Edit the [`deployment.yaml`](https://github.com/ivuorinen/docker-xmrig/blob/main/deployment.yaml) file. Things you may want to modify include:
|
||||||
|
|
||||||
|
- `replicas`: number of desired pods to be running. As I run a 3 worker node Turing Pi cluster, I run 3 replica's
|
||||||
|
- `image:tag`: to view all available versions, go to the [Tags](https://hub.docker.com/repository/docker/ivuorinen/docker-xmrig/tags) tab of the Docker Hub repo.
|
||||||
|
- `resources`: set appropriate values for `cpu` and `memory` requests/limits.
|
||||||
|
- `affinity`: the manifest will schedule only one pod per node, if that's not the desired behavior, remove the `affinity` block.
|
||||||
|
|
||||||
|
**Step 4:** Once you are satisfied with the above manifest, create a _deployment_:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -f apply deployment.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Logging
|
||||||
|
|
||||||
|
This Docker image sends the container logs to the `stdout`. To view the logs, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker logs xmrig
|
||||||
|
```
|
||||||
|
|
||||||
|
For Kubernetes run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl logs --follow -n xmrig <pod-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Persistent logging
|
||||||
|
|
||||||
|
Containers are stateless by nature, so their logs will be lost when they shut down.
|
||||||
|
If you want the logs to persist, enable XMRig syslog output in the [`config.json`][config.json] file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"syslog": true,
|
||||||
|
"log-file": "/xmrig/log/xmrig.log",
|
||||||
|
```
|
||||||
|
|
||||||
|
And give full permissions to the directory on the host machine:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod 777 "$(pwd)"/log
|
||||||
|
```
|
||||||
|
|
||||||
|
Then use either **Docker** [bind mounts](https://docs.docker.com/storage/bind-mounts/) or **Kubernetes** [Persistent Volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) to keep the log file on the host machine. The `docker run` command above and the [`docker-compose.yml`][docker-compose.yml] file already includes this mapping.
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
Use at your own disgression. This repository is by no means financial advise to mine
|
||||||
|
cryptocurrency. This is a project to learn how to build containerised applications.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Docker image is licensed under the terms of the [MIT License](https://github.com/ivuorinen/docker-xmrig/blob/main/LICENSE). XMRig is licensed under the GNU General Public License v3.0. See its [`LICENSE`](https://github.com/xmrig/xmrig/blob/master/LICENSE) file for details.
|
||||||
|
|
||||||
|
## Used works from other repositories
|
||||||
|
|
||||||
|
This repo is a based on works of:
|
||||||
|
|
||||||
|
- [jrkalf/xmrig-kryptokrona](https://github.com/jrkalf/xmrig-kryptokrona) for XMRIG for Kryptokrona
|
||||||
|
- [Roberto Meléndez](https://github.com/rcmelendez/xmrig-docker) for XMRIG for Monero
|
||||||
|
- [Bufanda](https://github.com/bufanda/docker-xmrig)
|
||||||
|
|
||||||
|
[config.json]: https://github.com/ivuorinen/docker-xmrig/blob/main/config.json
|
||||||
|
[docker-compose.yml]: https://github.com/ivuorinen/docker-xmrig/blob/main/docker-compose.yml
|
||||||
100
.github/workflows/build.yaml
vendored
Normal file
100
.github/workflows/build.yaml
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_IMAGE: ivuorinen/docker-xmrig
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm/v6
|
||||||
|
- linux/arm/v7
|
||||||
|
- linux/arm64
|
||||||
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Create manifest list and push
|
||||||
|
working-directory: /tmp/digests
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||||
|
- name: Inspect image
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
|
- name: Update repo description
|
||||||
|
uses: peter-evans/dockerhub-description@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
repository: ${{ env.REGISTRY_IMAGE }}
|
||||||
44
Dockerfile
Normal file
44
Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
ARG UBUNTU_VERSION="24.04"
|
||||||
|
ARG XMRIG_VERSION="v6.21.2"
|
||||||
|
|
||||||
|
FROM ubuntu:${UBUNTU_VERSION} as prepare
|
||||||
|
|
||||||
|
ENV TZ=Europe/Helsinki
|
||||||
|
ENV PATH=/xmrig:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
ENV XMRIG_URL=https://github.com/xmrig/xmrig.git
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
|
||||||
|
|
||||||
|
RUN git clone ${XMRIG_URL} /xmrig && \
|
||||||
|
cd /xmrig && git checkout ${XMRIG_VERSION}
|
||||||
|
|
||||||
|
WORKDIR /xmrig/build
|
||||||
|
RUN sed -i 's/1;/0;/g' ../src/donate.h
|
||||||
|
RUN cmake .. -DWITH_OPENCL=OFF -DWITH_CUDA=OFF && make -j$(nproc)
|
||||||
|
|
||||||
|
COPY config.json /xmrig/build/conf/
|
||||||
|
|
||||||
|
###
|
||||||
|
FROM ubuntu:${UBUNTU_VERSION}
|
||||||
|
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG VCS_REF
|
||||||
|
ARG XMRIG_VERSION
|
||||||
|
|
||||||
|
LABEL org.label-schema.build-date=$BUILD_DATE \
|
||||||
|
org.label-schema.vcs-url="https://github.com/ivuorinen/docker-xmrig" \
|
||||||
|
org.label-schema.vcs-ref=$VCS_REF \
|
||||||
|
org.label-schema.schema-version=$XMRIG_VERSION
|
||||||
|
|
||||||
|
WORKDIR /xmrig
|
||||||
|
|
||||||
|
COPY --from=prepare /xmrig/build/conf/config.json /xmrig/config.json
|
||||||
|
COPY --from=prepare /xmrig/build/xmrig /xmrig/xmrig
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get -y --no-install-recommends install libuv1 libhwloc15 \
|
||||||
|
&& apt-get purge -y --auto-remove \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& mkdir /xmrig/log
|
||||||
|
|
||||||
|
CMD ["/xmrig/xmrig", "-c", "/xmrig/config.json"]
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Ismo Vuorinen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
87
config.json
Normal file
87
config.json
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"api": {
|
||||||
|
"id": null,
|
||||||
|
"worker-id": null
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"enabled": false,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 0,
|
||||||
|
"access-token": null,
|
||||||
|
"restricted": true
|
||||||
|
},
|
||||||
|
"autosave": false,
|
||||||
|
"background": false,
|
||||||
|
"colors": true,
|
||||||
|
"title": true,
|
||||||
|
"randomx": {
|
||||||
|
"init": -1,
|
||||||
|
"init-avx2": -1,
|
||||||
|
"mode": "auto",
|
||||||
|
"1gb-pages": true,
|
||||||
|
"rdmsr": true,
|
||||||
|
"wrmsr": true,
|
||||||
|
"cache_qos": false,
|
||||||
|
"numa": true,
|
||||||
|
"scratchpad_prefetch_mode": 1
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
"enabled": true,
|
||||||
|
"huge-pages": true,
|
||||||
|
"huge-pages-jit": false,
|
||||||
|
"hw-aes": null,
|
||||||
|
"priority": null,
|
||||||
|
"memory-pool": false,
|
||||||
|
"yield": true,
|
||||||
|
"max-threads-hint": 100
|
||||||
|
},
|
||||||
|
"opencl": {
|
||||||
|
"enabled": false,
|
||||||
|
"cache": true,
|
||||||
|
"loader": null,
|
||||||
|
"platform": "AMD",
|
||||||
|
"adl": true,
|
||||||
|
"cn/0": false,
|
||||||
|
"cn-lite/0": false
|
||||||
|
},
|
||||||
|
"cuda": {
|
||||||
|
"enabled": false,
|
||||||
|
"loader": null,
|
||||||
|
"nvml": true,
|
||||||
|
"cn/0": false,
|
||||||
|
"cn-lite/0": false
|
||||||
|
},
|
||||||
|
"donate-level": 0,
|
||||||
|
"donate-over-proxy": 0,
|
||||||
|
"log-file": "/xmrig/log/xmrig.log",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"url": "tunkki:3333",
|
||||||
|
"user": "${HOSTNAME}",
|
||||||
|
"pass": "",
|
||||||
|
"keepalive": true,
|
||||||
|
"nicehash": false,
|
||||||
|
"variant": "trtl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"print-time": 60,
|
||||||
|
"health-print-time": 60,
|
||||||
|
"dmi": true,
|
||||||
|
"retries": 5,
|
||||||
|
"retry-pause": 5,
|
||||||
|
"syslog": true,
|
||||||
|
"tls": {
|
||||||
|
"enabled": false,
|
||||||
|
"protocols": null,
|
||||||
|
"cert": null,
|
||||||
|
"cert_key": null,
|
||||||
|
"ciphers": null,
|
||||||
|
"ciphersuites": null,
|
||||||
|
"dhparam": null
|
||||||
|
},
|
||||||
|
"user-agent": null,
|
||||||
|
"verbose": 0,
|
||||||
|
"watch": true,
|
||||||
|
"pause-on-battery": false,
|
||||||
|
"pause-on-active": false
|
||||||
|
}
|
||||||
47
deployment.yaml
Normal file
47
deployment.yaml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: xmrig
|
||||||
|
name: xmrig
|
||||||
|
namespace: xmrig
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: xmrig
|
||||||
|
strategy: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: xmrig
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: app
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- xmrig
|
||||||
|
topologyKey: "kubernetes.io/hostname"
|
||||||
|
containers:
|
||||||
|
- image: ivuorinen/docker-xmrig:latest
|
||||||
|
name: xmrig
|
||||||
|
command: ["/xmrig/xmrig"]
|
||||||
|
args: ["-c", "/xmrig/etc/config.json"]
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "2Gi"
|
||||||
|
cpu: "1"
|
||||||
|
requests:
|
||||||
|
memory: "1Gi"
|
||||||
|
cpu: "1"
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /xmrig/etc
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: xmrig-config
|
||||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
xmrig:
|
||||||
|
image: ivuorinen/docker-xmrig:latest
|
||||||
|
container_name: xmrig
|
||||||
|
#environment:
|
||||||
|
# - TZ=Europe/Amsterdam
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/xmrig/etc/config.json:ro
|
||||||
|
- ./log:/xmrig/log
|
||||||
|
command: ["/xmrig/xmrig", "--config=/xmrig/etc/config.json"]
|
||||||
|
restart: unless-stopped
|
||||||
Reference in New Issue
Block a user