How to run set up script on service container?

Hi Folks :wave:

I am trying to run an end-to-end (e2e) test suite on GitLab CI/CD Pipeline.
I am able to spin up my backend and a database for this job using these configurations:

    name: cypress/included:6.1.0
    entrypoint: [""]
      alias: frontend
      command: ["scripts/"]
      alias: app
    - name:
      alias: backend
      command: ["scripts/"]
    - name: postgres:13.0
      alias: database

The entire file is located here: gitlab/production-checks.yaml · master · Starting Spark / porter / frontend · GitLab

The issue I’m running into is: how do I set up my database prior to the start of the e2e testing?

I typically use my backend container to connect to and set up my database, e.g. migrate, seed, etc.
But the entrypoint/command for the backend service container is used to start my backend server.
Additionally, I don’t want an entrypoint/command that performs set up tasks each and every time.
Another issue is I don’t want to create and maintain another image just to run e2e tests in CI pipelines.

I could not find an option on services to run a one-off command on my service container listed here: Services | GitLab

Is there a pattern, setting, or a workaround to setup my database container prior to starting my e2e tests?

Thank you for your time :pray:

In case it helps anyone else…
I ended up making 2 of the same backend service containers. One runs the one-off setup command and the other starts up as the actual server.

It’s a bit hacky, but it works and it’s not too yucky of a workaround, I guess.

Thanks :pray: