Add entrypoint
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -1,8 +1,16 @@
|
|||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
WORKDIR /duino-coin/
|
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 .
|
COPY --chown=duco:duco duino-coin/requirements.txt duino-coin/PC_Miner.py entrypoint.sh ./
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
CMD ["python", "PC_miner.py"]
|
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"]
|
40
entrypoint.sh
Normal file
40
entrypoint.sh
Normal file
@@ -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" <<EOF
|
||||||
|
[PC Miner]
|
||||||
|
username="$DUCO_USERNAME"
|
||||||
|
mining_key="$ENCODED_KEY"
|
||||||
|
intensity=${DUCO_INTENSITY:-95}
|
||||||
|
threads=${DUCO_THREADS:-1}
|
||||||
|
start_diff=${DUCO_START_DIFF:-LOW}
|
||||||
|
donate=${DUCO_DONATE:-5}
|
||||||
|
identifier=${DUCO_IDENTIFIER:-$(hostname)}
|
||||||
|
algorithm=${DUCO_ALGORITHM:-DUCO-S1}
|
||||||
|
language=${DUCO_LANGUAGE:-english}
|
||||||
|
soc_timeout=${DUCO_SOC_TIMEOUT:-10}
|
||||||
|
report_sec=${DUCO_REPORT_SEC:-300}
|
||||||
|
raspi_leds=${DUCO_RASPI_LEDS:-y}
|
||||||
|
raspi_cpu_iot=${DUCO_RASPI_CPU_IOT:-y}
|
||||||
|
discord_rp=${DUCO_DISCORD_RP:-y}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Settings.cfg generated at $DUCO_DIR/Settings.cfg"
|
||||||
|
|
||||||
|
# Execute any command passed to the container
|
||||||
|
exec "$@"
|
Reference in New Issue
Block a user