Example nginx as service

Examples of nginx service on GitlabCI for e2e tests

We have a php application and we’re running Cypress tests for e2e testing. At the moment I’m using the Symfony server to run the backend, but as the tests grow that server is not performant enough.

  script:
    - /root/.symfony/bin/symfony server:start --port 8080 --no-tls 2>/dev/null &
    - echo "$!" >> /tmp/symfony-server.pid
    - wait-on http://localhost:8080/api

Instead I’d like to run nginx, it should be more performant, and it’s also what the production environment will run on.

I see two options:

  1. Use a container that includes the cypress and nginx required tooling, run the installation and configuration inline, and start the server with bash. e.g. /usr/bin/nginx -s start.
  2. Use an nginx service.

I’d prefer to use the service, as I suspect it will perform better (just a hunch). Plus it feels “cleaner” to keep the two things separate. What I’m looking for is a simplified example configuration for either of these set-ups. The examples in the docs are around database, which might be similar, but are thin on details. GitLab CI services examples | GitLab

I have the same question.

To use your Symfony app as a service would require you to put a latest version in a container registry and then link to that from the service.

Services | Gitlab

You’re not limited to only database services. You can add as many services you need to .gitlab-ci.yml or manually modify the config.toml. Any image found at Docker Hub or your private container registry can be used as a service.