Use files from repository in service on k8s runner

I have a postgresql image I want to use as a service, and use the provided initdb.d support to configure the postgresql db before it starts. On docker-based runners, /builds/$CI_PROJECT_PATH/ exists, and I can copy files from there to the right place, but on kubernetes that doesn’t seem to exist. How do I get files from the repository to the service container?

While the repository files are available to services, it’s a tricky setup and it might not have the results you expect.

The difference is that Docker mounts a volume with cached version of the repository files (from previous runs). Only after the services are running and helper/build container is starting the files are refreshed/checkout from repository. If you prune the Docker environment the first run will start to fail.

In Kubernetes there is no “cached volume” so there are no files the services can use. Files are pulled by helper container which might be later then the service container starts, you need to have a container that waits for the files to be present and only after that start whats needed.

So if I have the service sleep in the entry point until the files are checked out, that should work?