Skip to content

Commit b20488c

Browse files
authored
Merge pull request #273 from practical-python-org/buildcache
fix: better build cacheing
2 parents 8021562 + ead0b78 commit b20488c

File tree

5 files changed

+48
-33
lines changed

5 files changed

+48
-33
lines changed

Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ FROM python:3.11.6-slim-bullseye AS builder-image
22

33
ENV PYTHONUNBUFFERED=1
44

5-
COPY . /code
65
WORKDIR /code
76

8-
RUN pip install . && apt-get update && apt-get install -y ffmpeg
7+
RUN apt-get update && apt-get install -y ffmpeg
8+
9+
COPY requirements.txt /code/
10+
11+
RUN pip install -r requirements.txt
12+
13+
COPY setup.py /code/setup.py
14+
COPY setup.cfg /code/setup.cfg
15+
COPY versioneer.py /code/versioneer.py
16+
COPY pyproject.toml /code/pyproject.toml
17+
COPY README.md /code/README.md
18+
COPY src /code/src
19+
20+
RUN pip uninstall -y zorak && \
21+
pip install .
922

1023
ENTRYPOINT ["zorak"]

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ The easiest way to get started is to run Zorak locally and in our test server (C
3131
- -cl: Flag that enables streaming logs to console.
3232

3333
```bash
34-
pip install .
35-
zorak -dt <DISCORD_TOKEN_HERE> -ssp Resources/ServerConfig/Zorak-Dev -dd True -cl True
34+
docker-compose up -d
3635
```
37-
If you need to spin up the docker instances, you can by editing the .env file to reflect dev settings.
38-
1. Update the .env file to use 'dev' as the ENVIRONMENT
39-
2. Update your .env file to point the SETTINGS variable to Resources/ServerConfig/Zorak-Dev
40-
3. Run the command
36+
And then after making a change, rebuild only zorak.
4137
```bash
42-
docker-compose up -d
38+
docker build -t zorak .
39+
docker run --env-file ./.env zorak -dd True -dt <DISCORD_TOKEN_HERE>
4340
```
4441

42+
4543
### Production
4644
All environment settings are found in your .env file.
4745
1. Update the .env file to use 'prod' as the ENVIRONMENT
@@ -99,3 +97,4 @@ If your PR title does not include any of the specified prefixes, the GitHub Acti
9997
When your PR is merged into main, the GitHub Action will increment the version according to the prefix in the PR title and create a new tag.
10098

10199
Please ensure you follow this convention to maintain a well-structured and meaningful version history for our project.
100+

requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
py-cord
2+
beautifulsoup4
3+
requests
4+
matplotlib
5+
DateTime
6+
pytz
7+
pistonapi
8+
toml
9+
feedparser
10+
html2text
11+
pymongo
12+
PyNaCl==1.5.0
13+
ffmpeg-python==0.2.0
14+
yt-dlp==2023.10.13
15+
googletrans==3.1.0a0
16+
dnspython==2.3.0

setup.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
import pathlib
2+
3+
import pkg_resources
14
import setuptools
25

36
import versioneer
47

8+
install_requires = []
9+
with pathlib.Path("requirements.txt").open() as requirements_txt:
10+
install_requires = [str(requirement) for requirement in pkg_resources.parse_requirements(requirements_txt)]
11+
12+
513
setuptools.setup(
614
name="zorak",
715
description="An installable version of the Zorak.",
@@ -14,24 +22,7 @@
1422
packages=setuptools.find_packages(where="src"),
1523
entry_points={"console_scripts": ["zorak=zorak.__main__:main"]},
1624
package_data={"": ["*.toml"]},
17-
install_requires=[
18-
"py-cord",
19-
"beautifulsoup4",
20-
"requests",
21-
"matplotlib",
22-
"DateTime",
23-
"pytz",
24-
"pistonapi",
25-
"toml",
26-
"feedparser",
27-
"html2text",
28-
"pymongo",
29-
"PyNaCl==1.5.0",
30-
"ffmpeg-python==0.2.0",
31-
"yt-dlp==2023.10.13",
32-
"googletrans==3.1.0a0",
33-
"dnspython==2.3.0"
34-
],
25+
install_requires=install_requires,
3526
classifiers=[
3627
# see https://pypi.org/classifiers/
3728
"Development Status :: 5 - Production/Stable",

src/zorak/cogs/admin/admin_startup.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
from discord.ext import commands
99

10-
1110
logger = logging.getLogger(__name__)
1211

1312

1413
class OnStartup(commands.Cog):
1514
"""
1615
onStartup is called when the bot reaches a stable state.
1716
"""
17+
1818
def __init__(self, bot):
1919
self.bot = bot
2020

@@ -23,11 +23,7 @@ async def on_ready(self):
2323
"""
2424
Here's the juice. It's literally logging.
2525
"""
26-
logger.info(
27-
"Successfully logged in as {%s}/ ID: {%s}"
28-
, self.bot.user
29-
, self.bot.user.id
30-
)
26+
logger.info("Successfully logged in as {%s}/ ID: {%s}", self.bot.user, self.bot.user.id)
3127
logger.info("Started at: {%s}", datetime.now())
3228
logger.info("Greetings, puny earth-creature.")
3329

0 commit comments

Comments
 (0)