Initial cleanup as root?

Hi.

We have a gitlab instance, running Continuous Integration (CI).

Recently we started working on porting the application running in that CI, from Python 2.x to Python 3.x. Portions of the application are run in docker containers.

Things inside the containers are running as root, and are using volumes, which are bidirectional - so some things that are created inside the containers, as root, exist in the host filesystem.

Gitlab used to clean up Python 2.x’s *.pyc files no problem, even though they are owned by root, presumably because gitlab had write permission to the directory they were in.

However, with Python 3.x, *.pyc files are all created inside a __pycache__ directory, which is also owned by root. This prevents gitlab from cleaning up the __pycache__/*.pyc's.

Is there a good way of running gitlab’s initial cleanup as root? Right now, I believe it’s running as gitlab-runner.

I looked at our .gitlab-ci.yml, and it has some rm’s, but I think the rm in question is run before the .gitlab-ci.yml kicks in.

Our git-related variables look like:
variables:
GIT_STRATEGY: clone
GIT_CHECKOUT: “false”

Thanks!