Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline requirements - nginx/php stack - service link #6015

Open
b2p-fred opened this issue Nov 16, 2021 · 0 comments
Open

Pipeline requirements - nginx/php stack - service link #6015

b2p-fred opened this issue Nov 16, 2021 · 0 comments

Comments

@b2p-fred
Copy link

b2p-fred commented Nov 16, 2021

I have a specific pipeline configuration where i need to have some inter services communication. Indeed, I need to use a nginx / php-fpm stack for my Symfony application and the Nginx service uses the PHP service as an upstream.

As such, I need to know (and use) the PHP service name (or IP address) for the Nginx configuration in an environment variable.

Here is my pipeline code:

version: v1.0
name: deploy-backend
description: Deploy the application backend
jobs:
- job: Setup the application package
  steps:
  - artifactDownload:
      path: Download installable package
      pattern: epr-backend-api
      tag: '{{.cds.version}}'
  - script:
    - # Test that I get my application home page
    - curl -X GET http://nginx-api:80
    - echo "Result $?"
  requirements:
  - model: epr-PHP
  - service:
      name: mailer
      value: '{{.cds.proj.DOCKER_REGISTRY}}{{.cds.proj.DOCKER_REGISTRY_PREFIX}}epr-backend_mailer:{{.cds.proj.IMAGE_TAG_MAILER}} APP_ENV={{.cds.env.APP_ENV}}'
  - service:
      name: mariadb
      value: '{{.cds.proj.DOCKER_REGISTRY}}{{.cds.proj.DOCKER_REGISTRY_PREFIX}}epr-backend_db:{{.cds.proj.IMAGE_TAG_DB}} APP_ENV={{.cds.env.APP_ENV}} MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=false MARIADB_ROOT_PASSWORD={{.cds.env.DATABASE_ROOT_PASSWORD}} MARIADB_DATABASE={{.cds.env.DATABASE_NAME}} MARIADB_USER={{.cds.env.DATABASE_USER}} MARIADB_PASSWORD={{.cds.env.DATABASE_PASSWORD}}'
  - service:
      name: nginx-api
      value: '{{.cds.proj.DOCKER_REGISTRY}}{{.cds.proj.DOCKER_REGISTRY_PREFIX}}epr-backend_nginx:{{.cds.proj.IMAGE_TAG_NGINX}} HOSTNAME=nginx-api APP_ENV={{.cds.env.APP_ENV}} NGINX_PHP_UPSTREAM_HOST=php-api NGINX_PHP_UPSTREAM_PORT=9000 NGINX_PHP_UPSTREAM_COMMENT=n/a'
  - service:
      name: php-api
      value: '{{.cds.proj.DOCKER_REGISTRY}}{{.cds.proj.DOCKER_REGISTRY_PREFIX}}epr-backend_php:{{.cds.proj.IMAGE_TAG_PHP}} HOSTNAME=php-fpm APP_ENV={{.cds.env.APP_ENV}}'

With this configuration the nginx-api service fails to start because it cannot reach the php-api container.
When I replace php-api with 127.0.0.1 (or 172.17.0.1, or any pingable ip address) in the NGINX_PHP_UPSTREAM_HOST environment variable, the nginx-api starts correctly but my curl script fails because of a bad gateway.

Is there a solution to have the real address (or better, the hostname) of my php-api service container ?

**[edit]**indeed, one solution to get the service container hostname would be to be able to use the worker model name as a variable; see #5988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant