Mastodon.py icon indicating copy to clipboard operation
Mastodon.py copied to clipboard

Add Docker build / compose to prepare Mastodon Dev Env for vcr/cassette tests

Open arittner opened this issue 3 years ago • 10 comments

We need a stable local mastodon instance to prepare vcr/cassette tests. The idea is to create a docker build script with python from the existing docker build script and create an own image with only the needed services and features. Maybe an own docker compose script is enough.

Anyway, the containers should be used to prepare new recorded cassette files.

The build process to do this, is a manual step for developers with the interest to contribute new functionality and tests.

arittner avatar Jun 24 '22 09:06 arittner

cleaning up issues - it would be neat to have a quicker test setup, but I'm likely not doing it, I am not a Docker Person, so for now, there is a .sh script that can set up the server and run it via foreman, but no docker build or anything, install is manual.

anyone who wants to take this on, feel free to reopen.

halcy avatar Aug 16 '25 14:08 halcy

for now, there is a .sh script that can set up the server and run it via foreman

Is that public somewhere?

(I try to use Podman over Docker, but their API is largely the same).

Ryuno-Ki avatar Aug 26 '25 12:08 Ryuno-Ki

You know what, I thought it was, but actually, I forgot to check it in. I'll do it when I get home from work

halcy avatar Aug 26 '25 12:08 halcy

https://github.com/halcy/Mastodon.py/blob/master/tests/run_mastodon_for_tests.sh here it is!

halcy avatar Aug 26 '25 16:08 halcy

Okay, that looks like something to work with. (I'd have gone with SQLite over PostgreSQL for testing but I probably miss something). Next time I'm touching Mastodon.py I will get my hands on a Containerfile (the vendor-independent version of Dockerfile) and try to whip up something that does the same job.

Ryuno-Ki avatar Aug 26 '25 18:08 Ryuno-Ki

I don’t believe Mastodon supports any database engine other than Postgres…? Happy to be wrong about that, though. That would certainly simplify the setup

If you’re giving it a go, feel free to reopen this issue so you can use it to track work!

halcy avatar Aug 26 '25 18:08 halcy

I can see that it's not mentioned in the docs. (I'm running GoToSocial which implements Mastodon's API like so many other fedi apps). https://github.com/mastodon/mastodon/issues/29418#issuecomment-1973117456 shows that someone tried to read a SQL dump into SQLite.

In general Ruby on Rails support a handful of databases for which the database would need to be configured. I haven't tried it myself yet.

Ryuno-Ki avatar Aug 27 '25 18:08 Ryuno-Ki

To be honest, that already sounds like it would make the container quite complex to maintain. I think the most sensible way forward would be to install Mastodon in an as normal as possible way (apparently there is something called a "vagrantfile" for a dev setup, or a few guides for how to set up mastodon with docker like https://gist.github.com/melroy89/6fe7d05bdc0cfd2153b77310abf62990 - I can't find official docker install guides), then run the test setup stuff on top of it.

halcy avatar Aug 28 '25 06:08 halcy

Vagrant is a product by HashiCorp. About two years ago they switched the license and are no longer Open Source: https://www.hashicorp.com/de/blog/hashicorp-adopts-business-source-license

Might be acceptable for your use case as a hobby but could have implications downstream? I suggest you open a Discussion on this and ask for this community's opinion?

I'll wait either way (as my focus is with something else right now)

Ryuno-Ki avatar Aug 28 '25 11:08 Ryuno-Ki

I don't necessarily think that you'd want to use the exact thing, but I assume there's some kind of Official Mastodon Docker Install Process, and that it would be good to follow that, since these tests are intended to run against an as normal as possible (with some affordances for having to run tests) mastodon instance.

Though, if it's good enough for mastodon actual development, it should be good enough for us.

I'll reopen the issue, maybe some other people want to chime in on this...?

halcy avatar Aug 28 '25 14:08 halcy