-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from johndotpub/dev
Improve Dockerfile compatibility and performance
- Loading branch information
Showing
3 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
FROM python:3.12-alpine | ||
# Use Python 3.12 slim bullseye image for better compatibility and smaller size | ||
FROM python:3.12-slim-bullseye | ||
|
||
WORKDIR ~ | ||
COPY requirements.txt / | ||
RUN pip install -r /requirements.txt | ||
# Set the working directory to /app for better organization | ||
WORKDIR /app | ||
|
||
COPY . . | ||
# Copy requirements.txt to the container first | ||
# This allows Docker to cache the installed dependencies for faster builds | ||
# when your code changes but your dependencies do not | ||
COPY requirements.txt . | ||
|
||
# Install the Python dependencies | ||
# The --no-cache-dir option is used to keep the image size small | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the rest of the code into the container, excluding config.ini | ||
# Doing this after installing the dependencies allows Docker to cache the | ||
# installed dependencies separately from your code | ||
COPY . . | ||
RUN rm config.ini | ||
|
||
# Set the command to run the bot | ||
# The ENTRYPOINT instruction allows the container to be run as an executable | ||
# The CMD instruction provides default arguments that can be overridden | ||
ENTRYPOINT ["python", "bot.py"] | ||
CMD ["--conf", "config.ini"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters