Skip to content

Commit f440552

Browse files
Add Dockerfile, docker-compose and .dockerignore to conteinerize the bot
1 parent 8dcd856 commit f440552

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

docker/.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.env
6+
.env.*
7+
.vscode
8+
.idea
9+
.git
10+
.gitignore
11+
docker-compose.yml
12+
*.log
13+
*.sqlite3
14+
.DS_Store

docker/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Uses one of Playwright official images to handle all browser needed deps
2+
FROM mcr.microsoft.com/playwright/python:3.11
3+
4+
# Sets an environmental variable to prevent Python from generating .pyc files in the container
5+
ENV PYTHONDONTWRITEBYTECODE=1
6+
7+
# Sets an environmental variable to prevent Python from buffering outputs
8+
ENV PYTHONUNBUFFERED=1
9+
10+
# Install basic dependencies
11+
RUN apt-get update && apt-get install -y wget curl && rm -rf /var/lib/apt/lists/*
12+
13+
# Sets workdir
14+
WORKDIR /discord-bot
15+
16+
# Copy project requirement file and install them
17+
COPY requirements.txt ./
18+
RUN pip install --no-cache-dir -r requirements.txt
19+
20+
# Installs Playwright browsers
21+
RUN playwright install
22+
23+
# Copy other project files
24+
COPY . .
25+
26+
# Defines the command to run the bot when the conteiner starts
27+
CMD ["python", "src/main.py"]

docker/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.9'
2+
3+
services:
4+
a-voz-da-sasel-discord-bot:
5+
build:
6+
context: ..
7+
dockerfile: docker/Dockerfile
8+
image: sa-sel-discord-bot:latest
9+
container_name: a-voz-da-sasel
10+
env_file:
11+
- ./a-voz-da-sasel.env
12+
volumes:
13+
- ./a-voz-da-sasel.credentials.json:/discord-bot/credentials.json:ro
14+
restart: unless_stopped

0 commit comments

Comments
 (0)