Skip to content

Commit

Permalink
feat: docker additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekski1 committed Jul 2, 2024
1 parent d253b26 commit ebc27e8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ public.pem
*.session
parser.json
test_site.py

### Docker ###
Dockerfile
docker-compose.yml
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.3-slim


RUN apt-get update && apt-get install -y curl

# Installing Poetry using curl
RUN curl -sSL https://install.python-poetry.org | python3 -

#Adding Poetry to the PATH
ENV PATH="/root/.local/bin:$PATH"


COPY pyproject.toml poetry.lock /app/

#We give full access rights to the /app directory.
RUN chmod 777 /app

WORKDIR /app

#we install the dependencies specified in py project.tom l, excluding dev dependencies.
RUN poetry install --no-dev

COPY . /app

CMD ["poetry", "run", "python", "-u", "pyrogram_parser.py"]
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.7'

services:
parser:
build: .
volumes:
- .env:/app/.env # Attach the .env file to the container
networks:
- default # Connect the service to the default network

networks:
default:
driver: bridge
5 changes: 2 additions & 3 deletions pyrogram_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# File for saving data
filename = "parser.json"
# specify the name of the session file for userbot
app = Client(f"{os.getenv("PYROGRAM_SESSION_STRING")}")
app = Client(os.getenv("PYROGRAM_SESSION_STRING"))
# The url of the server
url = os.getenv("URL")

print(url)


class Chat(BaseModel):
id: int
Expand Down Expand Up @@ -54,6 +52,7 @@ async def saveJson(message_save):
data = json.load(file)
except json.JSONDecodeError:
data = []
print(f"save message: id = {message_save.id}")
data.append(message_save.serializableDict())
file.seek(0)
json.dump(data, file, ensure_ascii=False, indent=4)
Expand Down

0 comments on commit ebc27e8

Please sign in to comment.