diff --git a/Dockerfile b/Dockerfile index 7dbae6f..5e33163 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,16 @@ FROM python:3.11-slim WORKDIR /duino-coin/ +RUN useradd -m -s /bin/bash duco && \ + chown duco:duco -R /duino-coin/ +USER duco -COPY duino-coin/requirements.txt duino-coin/PC_miner.py . -RUN pip install --no-cache-dir -r requirements.txt +COPY --chown=duco:duco duino-coin/requirements.txt duino-coin/PC_Miner.py entrypoint.sh ./ -CMD ["python", "PC_miner.py"] \ No newline at end of file +ENV PATH="/home/duco/.local/bin:${PATH}" +RUN python3 -m pip install --upgrade pip --user && \ + pip install --no-cache-dir -r requirements.txt && \ + chmod +x /duino-coin/entrypoint.sh + +ENTRYPOINT [ "/duino-coin/entrypoint.sh" ] +CMD ["python", "PC_Miner.py"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..532fcb5 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Fail if required environment variables are not set +if [ -z "$DUCO_USERNAME" ] || [ -z "$DUCO_MINING_KEY" ]; then + echo "ERROR: DUCO_USERNAME and DUCO_MINING_KEY must be set." + exit 1 +fi + +# Base64-encode the mining key +ENCODED_KEY=$(echo -n "$DUCO_MINING_KEY" | base64) + +# Use environment variable DUCO_DIR or default to /duino-coin/Duino-Coin PC Miner 4.3 +DUCO_DIR="${DUCO_DIR:-/duino-coin/Duino-Coin PC Miner 4.3}" + +# Create the directory if it doesn't exist +mkdir -p "$DUCO_DIR" + +# Generate the Settings.cfg using environment variables or defaults +cat > "$DUCO_DIR/Settings.cfg" <