Skip to content

Commit

Permalink
updated dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginessi committed Jan 4, 2024
1 parent c53bdc2 commit 0d31018
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Stage 1: Build stage
FROM python:3.8-slim AS builder

# Set the working directory in the container
WORKDIR /app
# Set the working directory in the build stage
WORKDIR /build

# Copy only the necessary files into the container
COPY .env .
# Copy only the necessary files for installing dependencies
COPY requirements.txt .

# Install any needed packages specified in requirements.txt
# Install dependencies
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Copy the Python script into the container
# Stage 2: Runtime stage
FROM python:3.8-slim

# Set the working directory in the runtime stage
WORKDIR /app

# Copy only the necessary files into the runtime stage
COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
COPY .env .
COPY twitter.py .

# Run twitter.py when the container launches
Expand Down
11 changes: 7 additions & 4 deletions twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from web3 import Web3
from dotenv import load_dotenv
import os
import random # Import the random module

load_dotenv()

Expand Down Expand Up @@ -36,17 +37,19 @@ def get_block_message(block):

# Check the block type
if block_type == 'wrongfeerecipient':
# Post the tweet
# Post the tweet with some variation
address = block['withdrawal_address']
amount = Web3.from_wei(int(block['reward_wei']), 'ether')
return f"🚨❌ BANNED FROM SMOOTH ❌🚨 - {address} has been banned for sending {amount:.4f} ETH out of the pool"
variation = random.choice(["🚨❌", "πŸš«β—οΈ", "β›”"]) # Add some random variation
return f"{variation} BANNED FROM SMOOTH {variation} - {address} has been banned for sending {amount:.4f} ETH out of the pool"
elif block_type == 'okpoolproposal':
# Convert wei to ETH
w3 = Web3()
reward_eth = w3.from_wei(int(reward_wei), 'ether')

# Create tweet message
return f"🚨 NEW BLOCK IN SMOOTH 🚨 - {reward_eth:.4f} ETH from a ☁️ Smooth Operator 😏 (Block #{block_number}, Slot #{slot})"
# Create tweet message with some variation
variation = random.choice(["🚨", "πŸŽ‰", "πŸ’°"]) # Add some random variation
return f"{variation} NEW BLOCK IN SMOOTH {variation} - {reward_eth:.4f} ETH from a ☁️ Smooth Operator 😏 (Block #{block_number}, Slot #{slot})"
else:
print(f"Skipping tweet for block {block_number} (missing reward)")
return None
Expand Down

0 comments on commit 0d31018

Please sign in to comment.