Skip to content

Commit

Permalink
Merge pull request #15 from marctheshark3/db-dev
Browse files Browse the repository at this point in the history
Db dev
  • Loading branch information
marctheshark3 authored May 8, 2024
2 parents be45fcd + ca09b1f commit 43be73d
Show file tree
Hide file tree
Showing 20 changed files with 6,329 additions and 608 deletions.
27 changes: 19 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# Use an official Python runtime as a parent image
FROM python:3.8-slim
FROM python:3.9

# Set the working directory in the container
WORKDIR /usr/src/app
WORKDIR /app

# Copy the current directory contents into the container at /usr/src/app
COPY . /usr/src/app
# Copy the current directory contents into the container
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
# Install cron and Python dependencies
RUN apt-get update && apt-get -y install cron && \
pip3 install --no-cache-dir -r /app/requirements.txt

# Setup cron jobs
COPY utils/crontab_updates /etc/cron.d/crontab_updates
RUN chmod 0644 /etc/cron.d/crontab_updates && \
crontab /etc/cron.d/crontab_updates && \
touch /var/log/cron.log

# Make the entrypoint script executable and set it as the entrypoint
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# Make port 8050 available to the world outside this container
EXPOSE 8050

# Define environment variable
ENV FLASK_APP app.py

# Run the application
CMD ["gunicorn", "-w", "4", "--timeout", "2000", "-b", "0.0.0.0:8050", "app:server"]
# Command to run the application and cron jobs
CMD ["entrypoint.sh"]
55 changes: 55 additions & 0 deletions conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,58 @@ default_values:
url: 'https://api.ergo.aap.cornell.edu/api/v1/boxes/unspent/byAddress/'
token_ls: 'https://api.ergo.aap.cornell.edu/api/v1/tokens'
base_api: 'http://15.204.211.130:4000/api/pools/ErgoSigmanauts'
stats_cols: [
'fee NUMERIC', # Numeric type for precision
'paid NUMERIC', # Numeric type for decimal values
'blocks INTEGER', # Integer value for block counts
'last_block_found TIMESTAMP', # Timestamp for dates, assuming proper conversion before storage
'enabled BOOLEAN', # Boolean type for true/false
'minimumPayment NUMERIC', # Numeric type for precision of payments
'payoutScheme VARCHAR(255)', # String type for defined payout schemes
'connectedMiners INTEGER', # Integer for counting connected miners
'poolHashrate NUMERIC', # Numeric type for decimal values
'sharesPerSecond NUMERIC', # Numeric type for decimal values
'networkType VARCHAR(50)', # String type for network types
'networkHashrate NUMERIC', # Numeric type for hash rates
'networkDifficulty NUMERIC', # Numeric type for network difficulty
'lastNetworkBlockTime TIMESTAMP', # Timestamp for block times
'blockHeight INTEGER', # Integer for block height values
'connectedPeers INTEGER', # Integer for counting connected peers
'rewardType VARCHAR(50)', # String type for reward types
'poolEffort NUMERIC', # Numeric type for pool effort
'poolTTF NUMERIC', # Numeric type for pool time to find
'price NUMERIC',
'insert_time_stamp TIMESTAMP'] # Timestamp for the exact time data was recorded

block_cols: ['poolId VARCHAR(255)',
'blockHeight INTEGER',
'networkDifficulty NUMERIC',
'status VARCHAR(255)',
'confirmationProgress INTEGER',
'effort NUMERIC',
'transactionConfirmationData VARCHAR(255)',
'reward NUMERIC',
'infoLink VARCHAR(255)',
'hash VARCHAR(255)',
'miner VARCHAR(255)',
'source VARCHAR(255)',
'time_found VARCHAR(255)']

payment_headers: ['pendingShares NUMERIC',
'pendingBalance NUMERIC',
'totalPaid NUMERIC',
'todayPaid NUMERIC',
'Schema VARCHAR(50)',
'Price NUMERIC',
'lastPayment VARCHAR(50)',
'lastPaymentLink TEXT',
'participation NUMERIC',
'created_at TIMESTAMP',
'miner VARCHAR(100)']

live_worker_headers: ['worker VARCHAR(50)', 'hashrate NUMERIC', 'shares_per_second NUMERIC',
'created TIMESTAMP', 'miner VARCHAR(100)', 'effort NUMERIC',
'ttf NUMERIC', 'last_block_found VARCHAR(100)']

performance_headers: ['worker VARCHAR(50)', 'hashrate NUMERIC', 'shares_per_second NUMERIC',
'created TIMESTAMP', 'miner VARCHAR(60)', 'insert_time_stamp TIMESTAMP']
29 changes: 29 additions & 0 deletions docker-compose-diy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'

services:
db:
image: postgres:latest
environment:
POSTGRES_DB: mining-db
POSTGRES_USER: marctheshark
POSTGRES_PASSWORD: password
volumes:
- mining_data:/var/lib/postgresql/data
restart: unless-stopped
ports:
- "5431:5432"

app:
build:
context: .
dockerfile: Dockerfile # Make sure this is the name of your Dockerfile
volumes:
- ./:/app
ports:
- "8050:8050"
restart: unless-stopped
depends_on:
- db

volumes:
mining_data:
32 changes: 30 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
version: '3'
version: '3.8'

services:
pool-ui:
db:
image: postgres:latest
environment:
POSTGRES_DB: mining-db
POSTGRES_USER: marctheshark
POSTGRES_PASSWORD: password
volumes:
- mining_data:/var/lib/postgresql/data
restart: unless-stopped
ports:
- "5431:5432"

app:
build:
context: .
volumes:
- ./:/app
ports:
- "8050:8050"
restart: unless-stopped
depends_on:
- db

pool-ui:
image: ghcr.io/marctheshark3/sigmanaut-mining-pool-ui:main
ports:
- "8050:8050"
restart: unless-stopped
depends_on:
- db

volumes:
mining_data:
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

echo "Starting cron..."
cron
echo "Cron started."


# Run the database initialization script
python3 -m utils.init_db

# Start the web server with gunicorn
gunicorn -w 4 --timeout 2000 -b 0.0.0.0:8050 app:server
Loading

0 comments on commit 43be73d

Please sign in to comment.