Dockerize
JeroenDeDauw opened this issue · comments
Acceptance criteria:
- Stampy and its test suite can be run via Docker. This means there are no local dependencies beyond Docker, including no Python and no Anaconda.
Benefits:
- Easier getting started for new devs, esp those that do not frequently work with Python
- Avoid polluting dev machines with random dependencies
- Ensure dev/test/ci/prod run the exact same versions
Is docker available on Windows?
Is there any off-the-shelf mock environment for Discord API, Goose AI, ...? If not, there will be more trouble than benefits from setting up Docker to talk to the outside world correctly from all operating systems...
@tayler6000 there is https://docs.docker.com/desktop/install/windows-install/ .. but the user would need to install WSL2 and then Docker, I wouldn't exactly call that easier that installing Anaconda on Windows 🤷 Would be faster for people who don't work with Python but already have Docker, slower for people who work with Python but not yet with Docker.
IMHO not worth it yet, we have had more people willing to mess a bit with Python than people who can debug Docker files 😅 Might become more useful in the future.
@tayler6000 there is https://docs.docker.com/desktop/install/windows-install/ .. but the user would need to install WSL2 and then Docker, I wouldn't exactly call that easier that installing Anaconda on Windows 🤷
Why install anything when you have python -m venv venv
What is currently needed then?
- Python
- venv? Or does that come bundled?
- Anaconda? Or does that go via venv?
- Anything else not going via venv?
Having a Dockerized version does not force you do use Docker. You can keep using your current setup if you prefer.
Is there any off-the-shelf mock environment for Discord API, Goose AI, ...?
That question seems quite relevant for testing, but I'm not sure how it relates to Dockerizing.
debug Docker files
I certainly prefer having the setup instructions in version-controlled code that can be run by CI. The alternative is having them in README text that gets out of date and tends to be incomplete, because "obvious things" (to some) get omitted.
Yeah, I think the way to do this, that we've been doing so far but not very consistently, is to have the first task we ask any new devs to work on for the project be "Go through the readme to get a dev environment set up, and report any issues you have, preferably with a PR that updates the readme such that you wouldn't have had that issue". No setup issue need ever happen more than once
What is currently needed then?
Python
venv? Or does that come bundled?
Anaconda? Or does that go via venv?
Anything else not going via venv?
- Python 3.9
- venv comes prebundled on Windows, on Linux it depends but it's easily installed by
apt install python3-venv
if it's not on your flavor. - Anaconda is comparable to venv, with some extra bells and whistles. So it's up to your preference if you use Anaconda or venv. I use venv and production uses Anaconda.
- Everything else is just Python packages installed with pip in a venv or Anaconda environment.
Does pip also come bundled with python?
If you just need a standard version of python and nothing else, then there is indeed not much reason to Dockerize.
This is somewhat suggested by https://github.com/robertskmiles/stampy/blob/master/.github/workflows/unit-test-pull-request.yml, though idk if the Python on GitHub Actions is special somehow, for instance by having extra modules bundled.
Pip is also pre bundled with Python windows and almost always in Linux. But if your flavor doesn't for some reason it is also easily installed with apt install python3-pip
Ok, I'll give running the tests a try then later today and see if anything needs to be installed beyond python itself.
Didn't the bot use a DB? No dependency there?
Sqlite3 is built in to Python so no dependency there. Running tests does require unittest which can be installed with pip
Everything you need Python wise can be setup with the following commands
Windows:
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
Linux:
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
Try to remember to run python3? -m pip install --upgrade -r requirements.txt
every now and again to make sure your packages are up to date. (Please forgive my regex to support Windows and Linux haha)
Thanks for explaining
To be clear about how this would normally work with a Docker approach: you'd want the package manager (pip) installed in the Docker image, but not the packages that the package manager pulls in. So needing to run pip install
is not an argument for using Docker, assuming the runtime itself is already taken care of.